Jump to content
  • Advertisement
Sign in to follow this  
giugio

wmi and wql

This topic is 2494 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello.
I have the following code block:

HRESULT = pSvc HRES-> ExecQuery (
bstr_t ("WQL"). GetBSTR (),
bstr_t ("SELECT * FROM WHERE Win32_DiskDrive Win32_DiskDrive.DeviceID = '\ \ \ \. \ \ PHYSICALDRIVE0'"). GetBSTR (),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
& pEnumerator);



This code performs a WQL query (sql language type for the wmi) to find the disk that has deviceid equal to: \ \ \ \. \ \ PHYSICALDRIVE0.
The problem is that between the _bstr_t bstr etc. .. I do some mistake.

If i execute this query:

HRESULT = pSvc HRES-> ExecQuery (
bstr_t ("WQL"). GetBSTR (),
bstr_t ("SELECT FROM deviceid Win32_DiskDrive"). GetBSTR (),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
& pEnumerator);


I get
\ \ \ \. \ \ PHYSICALDRIVE0
and
\ \ \ \. \ \ PHYSICALDRIVE1
but when I execute the first query does not find anything (No Records = 0).


What do you think wrong?
Thank you.

Share this post


Link to post
Share on other sites
Advertisement
This might be totally wrong, but is

"

\ \ \ \. \ \ PHYSICALDRIVE0

"

correct? I mean has it pasted correctly? The slashes shouldn't have spaces between them.

Share this post


Link to post
Share on other sites
MSDN says the syntax of your queries are slightly malformed, and should be along these lines
select <properties> from <object> where <property> = <value>
This works:
select * from Win32_DiskDrive where DeviceID = '\\\\.\\PHYSICALDRIVE0'

If you're unaware, you can test queries through the wbemtest* utility that comes with Windows so you don't have to keep recompiling to execute them.

Click Start, click Run, type wbemtest, and then click OK.
In the Windows Management Instrumentation Tester dialog box, click Connect.
In the Connect dialog box, click Connect.
Click Query and enter your WQL query
Doble-click on any results to get the full class information

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!