我有以下过程来运行 WMI 查询,它运行良好。
procedure TFormMain.GetWMIOSInfo(const RemoteMachine, Username, Password: string);
var
FSWbemLocator: OLEVariant;
FWMIService: OLEVariant;
FWbemObjectSet: OLEVariant;
FWbemObject: OLEVariant;
oEnum: IEnumvariant;
iValue: LongWord;
begin;
try
FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
FWMIService := FSWbemLocator.ConnectServer(RemoteMachine, 'root\CIMV2', Username, Password);
FWbemObjectSet := FWMIService.ExecQuery(
'select screenwidth, screenheight, status from Win32_DesktopMonitor','WQL', 0);
try
oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
while oEnum.Next(1, FWbemObject, iValue) = 0 do
begin
Listbox1.Items.Add(
VarToStr(FWbemObject.availability) + ', ' +
VarToStr(FWbemObject.screenwidth) + ', ' +
VarToStr(FWbemObject.screenheight));
FWbemObject := Unassigned;
end;
finally
FWbemObjectSet := Unassigned;
end;
Except on E: Exception do
Raise;
end;
end;
我想更改查询以返回所有字段,例如select * from Win32_DesktopMonitor
. 我的问题是我不知道如何确定查询返回的列的名称FWbemObject
。IE。我想列举FWbemObject
.
Listbox1.Items.Add(
VarToStr(FWbemObject.<?>) + ', ' +
VarToStr(FWbemObject.<?>) + ', ' +
....
VarToStr(FWbemObject.<?>));