Reputation: 353
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;
Upvotes: 0
Views: 123
Reputation: 353
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.
Upvotes: 1