wmi-delphi-code-creator
wmi-delphi-code-creator copied to clipboard
WQL Syntax "Where" is not working
Select * from Win32_NetworkAdapterConfiguration where.....
it's WQL is not working.
Check, pls.
Powershell is working it
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