Reputation: 605
Hello How to get data from this array? Or how to get all the names that I can extract?
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));
}
Upvotes: 1
Views: 1710
Reputation: 136431
Your code is not working because the results of the ExecNotificationQueryAsync
method must be processed using a IWbemObjectSink
object. Try this MSDN sample Receiving Event Notifications Through WMI
Also you can use a tool like the WMI Delphi Code Creator
to generate C++ Code to access the WMI.
Upvotes: 1