Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IWbemClassObject::Get()

Status
Not open for further replies.

AgentOrange44

Programmer
Apr 6, 2005
13
US
I need help using the Get() function from IWbemClassObject. I've used this function before to return single values, but the problem I'm having is I can't seem to figure out how to handle multi-valued results. My query looks like this:

hr = objWMIService->ExecQuery(L"WQL", L"Select * From Win32_NetworkAdapterConfiguration Where IPenabled = 'True'", WBEM_FLAG_FORWARD_ONLY, NULL, &ppEnum);

After this I get the IWbemClassObject object from ppEnum and start getting attributes with the Get() function. I can successfully retrieve single values, but when I try to get the IPAddress, which is an array of multiple IPs, I can't figure out what to do with the result. I'm porting some VBScript code to C++, so here is the VB and C++ code:

(VBScript)
Wscript.StdOut.Write vbCrLF & "IP Address : " & Instance.IPAddress(0)

(my C++ code)
hr = objInstance->Get(L"IPAddress", 0, &var, NULL, 0);

When I debug, var is set to an unknown type (???) after the get function. I've tried converting var to a SAFEARRAY but when I try to enumerate the array there doesn't seem to be anything there. Also, initializing var to VT_ARRAY before calling Get doesn't do anything either.

Info on Win32_NetworkAdapterConfiguration can be found here:
This is driving me crazy and I can't find much on the net about implementing IWbem classes with C++, so I would appreciate any help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top