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 ManagementObjec tCollection = mc.GetInstances
Dim mo As ManagementObjec t
For Each mo In moc
Dim p As New ROOT.CIMV2.Proc ess(mo) '<--error here
Dim processDomain, processUser As String
p.GetOwner(proc essDomain, processUser)
If processUser = userName Then
bUser = True
End If
Next
End Sub
----------------------------------------------
I made a reference to System.Manageme nt and also using
Imports System.Manageme nt
This following example works OK
---------------------------------------------
Public Sub ManagementScope GetObjectThing( )
Dim scope As New ManagementScope ("\\.\root\cimv 2")
scope.Connect()
Dim objectQuery As New ObjectQuery("se lect * from
Win32_Operating System")
Dim searcher As New ManagementObjec tSearcher(scope ,
objectQuery)
Dim os As ManagementObjec t
For Each os In searcher.Get()
Console.WriteLi ne("OS = " & os("Name").ToSt ring())
Console.WriteLi ne(" Free memory = " & os
("FreePhysicalM emory").ToStrin g())
Next os
End Sub
--------------------------------------------------
How can I reference ROOT.CIMV2.Proc ess from the 1st
example?
For Each mo In moc
Dim p As New ROOT.CIMV2.Proc ess(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
-----Original Message-----
Rich,
Take a look at the System.Manageme nt namespace - classes
included withinthis namespace are managed wrapper classes created around
the original WMIclasses. You probably shouldn't need to use GetObject
then (unless you havesome other purpose to use it). Here are some links to get
you started usingthese classes:
http://msdn.microsoft.com/library/?url=/library/en-
us/cpguide/html/cpconmanagingap plicationsusing wmi.asp?
frame=truehttp://msdn.microsoft.com/library/default.asp?
url=/library/en-us/dnhcvs04/html/vs04d6a.asphttp://www.devx.com/dotnet/Article/20162
hope that helps..
Imran.
"Rich" <an*******@disc ussions.microso ft.com> wrote in
messagenews:0a******* *************** ******@phx.gbl. .. Greetings,
I am trying to find a way to use a form of GetObject in
VB.Net and have been researching WMI. Apparently, this
is a vast subject, but seems to reference a Namespace
called Root.CIMV2. Does anyone know how to access this
namespace?
Thanks,
Rich
.