wmi-delphi-code-creator icon indicating copy to clipboard operation
wmi-delphi-code-creator copied to clipboard

WQL Syntax "Where" is not working

Open bluems opened this issue 7 years ago • 1 comments

Select * from Win32_NetworkAdapterConfiguration where.....

it's WQL is not working.

Check, pls.

Powershell is working it

bluems avatar Apr 17 '18 18:04 bluems

In my specific case I wanted to modify generated Free Pascal code to query one specific Win32_Process instead of all of them.

Generated query statement: FWbemObjectSet:= FWMIService.ExecQuery('SELECT * FROM Win32_Process','WQL',wbemFlagForwardOnly);

The following naive modification does not work (and thus seems to reproduce the above error) - this should be one line: FWbemObjectSet:= FWMIService.ExecQuery('SELECT * FROM Win32_Process WHERE ProcessId='+intToStr(GetProcessID),'WQL',wbemFlagForwardOnly);

What did finally work was to assign the very same query to a variable of type OLEVariant first. query:='SELECT * FROM Win32_Process WHERE ProcessId='+intToStr(GetProcessID); FWbemObjectSet:= FWMIService.ExecQuery(query,'WQL',wbemFlagForwardOnly);

Hope that helped. Martin

Sorry. I forgot to specify; OS: Windows 10, Compiler: FPC 3.2.0 for Win64

mschlegel81 avatar Aug 29 '20 02:08 mschlegel81