I'm quite new to WMI, I'm following this guide here .
So I pasted that code in the guide and ran it without any issues using the provided query. But when I changed the query to SELECT State FROM Win32_Service
I get no data, just the error code 0xC0000005, which I believe is a permissions error?
That same query above works just fine in the PowerShell using the following command:
Get-WmiObject -Query "select State from Win32_Service"
What I've tried
So what gives? Why am I having trouble querying the WMI from my C++ code?
EDIT: I found the line that's causing the crash. I'm not sure why it's crashing though.
wcout << vtProp.bstrVal << endl;
I missed this line of code
hr = pclsObj->Get(L"State", 0, &vtProp, 0, 0);
Change the first argument to the property whose value you'd like to retrieve.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.