gpt4 book ai didi

c++ - 如何获取数据 IWbemClassObject **

转载 作者:行者123 更新时间:2023-11-28 07:38:25 25 4
gpt4 key购买 nike

你好如何从这个数组中获取数据?或者如何获取我可以提取的所有名称?

hres = pSvc->ExecNotificationQueryAsync( _bstr_t("WQL"), _bstr_t("SELECT * " 
"FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_Process'"),
WBEM_FLAG_SEND_STATUS, NULL, pStubSink);
for (int i = 0; i < lObjectCount; i++)
{
VARIANT varName;
hres = apObjArray[i]->Get(_bstr_t(L"__CLASS"),
0, &varName, 0, 0);

if (FAILED(hres))
{
cout << "Failed to get the data from the query"
<< " Error code = 0x"
<< hex << hres << endl;
return WBEM_E_FAILED; // Program has failed.
}

printf("Name: %ls\n", V_BSTR(&varName));
}

最佳答案

您的代码无法正常工作,因为 ExecNotificationQueryAsync 的结果必须使用 IWbemObjectSink 处理方法目的。试试这个 MSDN 示例 Receiving Event Notifications Through WMI您也可以使用类似 WMI Delphi Code Creator 的工具生成 C++ 代码以访问 WMI。

关于c++ - 如何获取数据 IWbemClassObject **,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16316485/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com