(Gast)
n/a Beiträge
|
AW: Windows Version ermitteln
23. Mai 2024, 19:17
Hallo,
mit WMI funktioniert es.
Delphi-Quellcode:
procedure GetCIM_OperatingSystemInfo;
const
WbemUser = ' ';
WbemPassword = ' ';
WbemComputer = ' localhost';
wbemFlagForwardOnly = $00000020;
var
FSWbemLocator,
FWMIService,
FWbemObjectSet,
FWbemObject: OLEVariant;
oEnum: IEnumvariant;
iValue: LongWord;
begin;
FSWbemLocator := CreateOleObject(' WbemScripting.SWbemLocator');
FWMIService := FSWbemLocator.ConnectServer(WbemComputer, ' root\CIMV2', WbemUser, WbemPassword);
FWbemObjectSet := FWMIService.ExecQuery(' SELECT * FROM CIM_OperatingSystem', ' WQL', wbemFlagForwardOnly);
oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
while oEnum.Next(1, FWbemObject, iValue) = 0 do
begin
memo1.Lines.add(FWbemObject.Caption); //<<------ müsste entsprechend angepasst werden.
FWbemObject:=Unassigned;
end;
end;
aufruf
Delphi-Quellcode:
begin
try
memo1.Lines.clear;
coInitialize( nil);
try
GetCIM_OperatingSystemInfo;
finally
CoUninitialize;
end;
except
on E:EOleException do
showmessage(Format(' EOleException %s %x', [E. Message,E.ErrorCode]));
on E: Exception do
ShowMessage(E.Classname+' : '+ E. Message);
end;
end;
ich habe es hiermit erstellt.
https://github.com/RRUZ/wmi-delphi-code-creator
Gruß
|
|
Zitat
|