为什么我会从Win32_Volume类的Defraganalysis方法中获得未知错误? [英] Why Do I Get Unknown Error From Defraganalysis Method Of The Win32_Volume Class?
本文介绍了为什么我会从Win32_Volume类的Defraganalysis方法中获得未知错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
代码如下:
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;
hres = pSvc-> ExecMethod (vtProp.bstrVal, MethodName, 0,
//vtProp.bstrVal
NULL, NULL, &pOutParams, NULL);
hres = pOutParams->Get(L"ReturnValue", 0,
&***varReturnValue***,
NULL, 0);
VariantClear(&varReturnValue);
}
但是我得到11个ReturnValue女巫的vaule意味着未知错误可能有人帮助,我一直在寻找一个解决方案天
i不知道问题是在ExecMethod的参数列表中还是其他什么?
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?
推荐答案
hres = pSvc-> ExecMethod (vtProp.bstrVal, MethodName, 0,
//vtProp.bstrVal
NULL, NULL, &pOutParams, NULL);
第一个参数应该是ClassName。
不太熟悉一种代码,但我相信pOutparams应该指向一个结构来获取Defrag调用的返回值。
The first argument should be a ClassName.
Not too familiar with that kind of code, but I believe that the pOutparams should point on a structure to get the return value of the Defrag call.
这篇关于为什么我会从Win32_Volume类的Defraganalysis方法中获得未知错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文