Link to home
Start Free TrialLog in
Avatar of fbru02
fbru02

asked on

Querying the WMI and getting back an UInt32

Hi all,

I;m querying the WMI and I have a problem when getting the Data from the Variant that I get: I do this :
 hres = pSvc->ExecQuery(
              bstr_t("WQL"),
              bstr_t("Select * from Win32_DisplayConfiguration"),
              WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
              NULL,
              &pEnumerator);
          
      
          IWbemClassObject *pclsObj;
          ULONG uReturn = 0;
            ////////
            std::string endresult;
        
          while (pEnumerator)
          {
              HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1,
                  &pclsObj, &uReturn);

              if(0 == uReturn)
              {
                  break;
              }

              VARIANT vtProp;

              // Get the value of the Name property
              hr = pclsObj->Get(L"BitsPerPel", 0, &vtProp, 0, 0);
                  endresult = _bstr_t (vtProp.bstrVal);

This does not work because the result evaluated in the Variant vtProp is not a bstr but a UInt32.
If I do that I get a pointer error.

How can I evaluate the result knowing that the property in the Variant vtProp is an UInt32? vtProp.???

Kind Regards and Thanks
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BTW, see also http://msdn2.microsoft.com/en-us/library/ms891678.aspx ("VARIANT and VARIANTARG")
Avatar of fbru02
fbru02

ASKER

yea it was vtProp.lVal ... hehe what was i thinking ? :)