Using Msvm_SummaryInformation class running into a issues

  • Thread starter Thread starter ananda vardhana
  • Start date Start date
A

ananda vardhana

Guest
Hi

This is code snippet from one of MSFT documentation

Example: Getting WMI Data from the Local Computer - Win32 apps
The example does the Win32_OperatingSystem and it works fine. I replaced Win32_OperatingSystem with Msvm_SummaryInformation
now uReturn returns 0 :(. . My guess I have to change either pEnumerator object or something else to make it compatible with Msvm_SummaryInformation.
I tried lot of things none seemed to work
Please help me out or point me to a C++ program using Msvm_SummaryInformation


Thanks a lot




// For example, get the name of the operating system
IEnumWbemClassObject* pEnumerator = NULL;
hres = pSvc->ExecQuery(
bstr_t("WQL"),
bstr_t("SELECT * FROM Msvm_SummaryInformation"), // Win32_OperatingSystem
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator);

if (FAILED(hres))
{
cout << "Query for operating system name failed."
<< " Error code = 0x"
<< hex << hres << endl;
pSvc->Release();
pLoc->Release();
CoUninitialize();
return 1; // Program has failed.
}

// Step 7: -------------------------------------------------
// Get the data from the query in step 6 -------------------

IWbemClassObject *pclsObj = NULL;
ULONG uReturn = 0;

while (pEnumerator)
{
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1,
&pclsObj, &uReturn);

if(0 == uReturn)
{
break;
}

Continue reading...
 
Back
Top