Thanks for these references. I downloaded the sample
application. But here is an example I was originally
working with where vb.Net was complaining
------------------------------------------
Private Sub IsUserLoggedIn()
Dim userName As String = "rich"
Dim bUser As Boolean
Dim mc As New ManagementClass("Win32_Process")
Dim moc As ManagementObjectCollection = mc.GetInstances
Dim mo As ManagementObject
For Each mo In moc
Dim p As New ROOT.CIMV2.Process(mo) '<--error here
Dim processDomain, processUser As String
p.GetOwner(processDomain, processUser)
If processUser = userName Then
bUser = True
End If
Next
End Sub
----------------------------------------------
I made a reference to System.Management and also using
Imports System.Management
This following example works OK
---------------------------------------------
Public Sub ManagementScopeGetObjectThing()
Dim scope As New ManagementScope("\\.\root\cimv2")
scope.Connect()
Dim objectQuery As New ObjectQuery("select * from
Win32_OperatingSystem")
Dim searcher As New ManagementObjectSearcher(scope,
objectQuery)
Dim os As ManagementObject
For Each os In searcher.Get()
Console.WriteLine("OS = " & os("Name").ToString())
Console.WriteLine(" Free memory = " & os
("FreePhysicalMemory").ToString())
Next os
End Sub
--------------------------------------------------
How can I reference ROOT.CIMV2.Process from the 1st
example?
For Each mo In moc
Dim p As New ROOT.CIMV2.Process(mo) '<--error here
Note: my actual objective is to be able to capture a dll
object (of my creation) which is already running (already
been instantiated from a first application) and be able to
read data from this dll object from a 2nd application
which has also has a reference to this dll. The first
application passes/writes data to a property in the dll.
I want to read this data contained in the active dll from
the 2nd application (a separate application but part of
the same project). I WMI a way that I could achieve this?
In Microsoft Office I can pass a vb6 dll object from MS
Access to MS Excel. I load the vb6 dll with data from
Access, pass the dll as argument to Excel using
automation, and Excel can read the contents of the dll.
Surely, a vb.net dll can do the same thing, but how?
Note: I use createObject to invoke the Excel application
and then open a specific workbook, then call a procedure
in the Excel workbook from Access and pass the vb6 dll as
an argument. I would like to be able to do something
similar to the Access/Excel paradigm in vb.net. But
Access and Excel are ActiveX applications. How could I
achieve similar functionality in my vb.net applications?
Thanks,
Rich