对BcdStore类的OpenObject方法的执行调用失败. hr = pSvc-> ExecMethod(bstrObjectName,bstrMthdName ,0,NULL,pInParam,& pOutParam,& pCallResult); pSvc-> Release(); pLoc-> ; Release(); CoUninitialize(); 返回0; }hr = pSvc->ExecMethod(bstrObjectName, bstrMthdName, 0, NULL, pInParam, &pOutParam, &pCallResult);推荐答案替换此: hr = pSvc-> ExecMethod(bstrObjectName,bstrMthdName,0,NULL,pInParam,& pOutParam,& pCallResult); 与此: VARIANT vPath;Replace this: hr = pSvc->ExecMethod(bstrObjectName, bstrMthdName, 0, NULL, pInParam, &pOutParam, &pCallResult); With this:VARIANT vPath; BSTR strClassProp = SysAllocString(L ; __ RELPATH"; );BSTR strClassProp = SysAllocString(L"__RELPATH"); HRESULT小时;HRESULT hr; hr = pGotBcdStore-> Get(strClassProp,0,& vPath,0,0);hr = pGotBcdStore->Get(strClassProp, 0, &vPath, 0, 0); SysFreeString(strClassProp);SysFreeString(strClassProp); //检查HRESULT以查看操作是否成功.// check the HRESULT to see if the action succeeded. 如果 (SUCCEEDED(hr)&&(V_VT(& vPath)== VT_BSTR) )if (SUCCEEDED(hr) && (V_VT(&vPath) == VT_BSTR)) { wprintf(L "类名是%s \ n." ,V_BSTR(& vPath)); wprintf(L"The class name is %s\n.", V_BSTR(&vPath));} 其他else { wprintf(L "获取指定对象时出错\ n" );wprintf(L"Error in getting specified object\n");} hr = pSvc-> ExecMethod(V_BSTR(& vPath),bstrMthdName,0,NULL,pInParam,& pOutParam,& pCallResult);hr = pSvc->ExecMethod(V_BSTR(&vPath), bstrMthdName, 0, NULL, pInParam, &pOutParam, &pCallResult); VariantClear(& vPath);VariantClear(&vPath); 这篇关于使用WMI API编辑BCD数据的代码帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-13 13:10