Link to home
Start Free TrialLog in
Avatar of Valty
ValtyFlag for France

asked on

WMI problem to retrieve LogicalDisk Size & FreeSpace

Hello,

I have a problem to retrieve the size and free space of logical disks via WMI.

The values are uint64 type, but impossible to retrieve them into the VARIANT struct.

The problem seems to be with the uint64 types only...

Anybody have a solution ?

(My code is bellow... works perfectly with other classes)
...
 
    if (FAILED(pSvc->ExecQuery(
        BSTR(L"WQL"),
        BSTR(L"SELECT * FROM Win32_LogicalDisk"),
        WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, 
        NULL,
        &pEnumerator)))printf("erreur - ExecQuery\n");
    else
    { 
        IWbemClassObject *pclsObj;
        ULONG uReturn = 0;
   
        while (pEnumerator)
        {
            pEnumerator->Next(WBEM_INFINITE, 1,&pclsObj, &uReturn);
            if (0 == uReturn) break;
            VARIANT vtProp;
 
            pclsObj->Get(L"Size", 0, &vtProp, 0, 0);
            printf("=> %lld\n", vtProp.uintVal); // here is the problem...
 
            VariantClear(&vtProp);
            pclsObj->Release();
        }
        pEnumerator->Release(); 
    }
 
...

Open in new window

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
Avatar of Valty

ASKER

Perfect, thanks ;-)

PS: have you found a solution for my service screenshot problem ?