ala_2 0 Newbie Poster

the code is the following :

BSTR MethodName = SysAllocString(L"DefragAnalysis");
BSTR ClassName = SysAllocString(L"Win32_Volume");

IWbemClassObject* pClass = NULL; 
hres = pSvc-> GetObject (ClassName, 0, 0, &pClass, 0); 

IEnumWbemClassObject* pEnumerator = NULL; 
hres = pSvc-> ExecQuery ( 
    bstr_t ("WQL"),  
    bstr_t ("SELECT * FROM Win32_Volume"), 
    WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,  
    NULL, 
    &pEnumerator); 

IWbemClassObject *pclsObj; 
ULONG uReturn = 0; 

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

    if (0 == uReturn) 
    { 
        break; 
    }
    VARIANT vtProp;

            if(FAILED(pclsObj->Get(L"__Path", 0, &vtProp, NULL, NULL)))  
            {  
             cout << "Object has no __Path!" << endl;  
             pclsObj->Release();  
             continue;  
             }  
            int test =0;
            //Execute Method 
            IWbemClassObject* pOutParams = NULL; 
            VARIANT varReturnValue;
enter code here
            hres = pSvc-> ExecMethod (vtProp.bstrVal, MethodName, 0,     
                           //vtProp.bstrVal
            NULL, NULL, &pOutParams, NULL); 
            hres = pOutParams->Get(L"ReturnValue", 0, 
                            &***varReturnValue***, 
                            NULL, 0);
            VariantClear(&varReturnValue);

}

but i get a vaule of 11 of ReturnValue witch means Unknown error could someone help,i 've been looking for a solution for days

i dont know if the problem is in the list of Parameters of ExecMethod or anything else?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.