Root.CIMV2 namespace - how to access it?

  • Thread starter Thread starter Rich
  • Start date Start date
R

Rich

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
 
Rich,

Take a look at the System.Management namespace - classes included within
this namespace are managed wrapper classes created around the original WMI
classes. You probably shouldn't need to use GetObject then (unless you have
some other purpose to use it). Here are some links to get you started using
these classes:

http://msdn.microsoft.com/library/?...onmanagingapplicationsusingwmi.asp?frame=true
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnhcvs04/html/vs04d6a.asp
http://www.devx.com/dotnet/Article/20162

hope that helps..
Imran.
 
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
 
Back
Top