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"), 

IWbemClassObject *pclsObj; 
ULONG uReturn = 0; 

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

    if (0 == uReturn) 
    VARIANT vtProp;

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


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 meeting, networking, learning, and sharing knowledge.