(WMI) ExecMethod out parameter - ResultingSnapshot is NULL irrespective of the result of the call, Why?

前端 未结 3 627
醉话见心
醉话见心 2020-12-06 08:01

I am using WMI to create an RCT Checkpoint. Below is the code snippet. The problem is when I call the method Create Snapshot using ExecMethodthe ch

3条回答
  •  自闭症患者
    2020-12-06 09:03

    HRESULT GetRelated(PWSTR sAssociatePath, PWSTR sResultClass, IWbemClassObject** ppResultObject)
    {
    CStringW query;
    query.Format(L"associators of {%s} where ResultClass = %s", sAssociatePath, sResultClass);
    
    CComPtr pEnumOb;
    
    HRESULT hr = m_pWbemServices->ExecQuery(
        BSTR(L"WQL"),
        CComBSTR(query),
        WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
        NULL,
        &pEnumOb));
    ULONG uReturn = 0;
    CComPtr pObject;
    hr = pEnumOb->Next(WBEM_INFINITE, 1, &pObject, &uReturn);
    return hr;
    }
    // Call the GetRelated function above with the __PATH parameter of JOB
    CComPtr pOutParam = NULL;
    CHK_HRES(this->ExecMethod(pHyperVObject, L"ConvertToReferencePoint", pInParams, &pOutParam, NULL));
    CComVariant jobPath;
    CHK_HRES(pOutParam->Get(L"Job", 0, &jobPath, NULL, NULL));
    CComPtr pResult;
    GetRelated(jobPath.bstrVal, L"Msvm_VirtualSystemReferencePoint", &pResult);
    

提交回复
热议问题