jindalee
asked on
ManagementObjectCollection usage
I am trying to use the ManagementObjectCollection class to get some system information. However, the attcahed code snippet gives me the errors:
"ManagementClass not defined"
"ManagementObjectCollectio n not defined"
"ManagementObjectCollectio n.Manageme ntObjectEn umerator" not defined.
From what I can see in MSDN, I have to import System and System.Management to get these classes.
I have both imports in my code but still get the errors.
I am using Visual Studio.Net (Visual Basic 2008) on a WinXP SP3, .Net 3,.5 PC.
Can someone please advise what I am missing.
Thanks
"ManagementClass not defined"
"ManagementObjectCollectio
"ManagementObjectCollectio
From what I can see in MSDN, I have to import System and System.Management to get these classes.
I have both imports in my code but still get the errors.
I am using Visual Studio.Net (Visual Basic 2008) on a WinXP SP3, .Net 3,.5 PC.
Can someone please advise what I am missing.
Thanks
Dim ManClass As ManagementClass = New ManagementClass("Win32_ComputerSystem")
Dim ManObj As ManagementObjectCollection = ManClass.GetInstances()
Dim ManOblCollection As ManagementObjectCollection.ManagementObjectEnumerator = ManObj .GetEnumerator
ManOblCollection .MoveNext()
s = ManOblCollection .Current.Properties("CurrentTimeZone").Value.ToString()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you. I found that I had to add theimports as references even though I had them at the top of the source file. Works a treat.
I didn't get a chance to respond. Did you answer your own question about adding a reference?
ASKER
IMports System
IMports System.Management
Is that differenmt from adding a reference?