procedure GetWin32_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 Win32_OperatingSystem', '
WQL', wbemFlagForwardOnly);
oEnum := IUnknown(FWbemObjectSet._NewEnum)
as IEnumVariant;
while oEnum.Next(1, FWbemObject, iValue) = 0
do
begin
memo1.Lines.add(Format('
BootDevice %s',[
String(FWbemObject.BootDevice)]));
Memo1.Lines.add(Format('
BuildNumber %s',[
String(FWbemObject.BuildNumber)]));
// String
Memo1.Lines.Add(Format('
Caption %s',[
String(FWbemObject.Caption)]));
// String
FWbemObject:=Unassigned;
end;
end;
begin
try
memo1.Lines.Clear;
CoInitialize(
nil);
try
GetWin32_OperatingSystemInfo;
finally
CoUninitialize;
end;
except
on E:EOleException
do
Writeln(Format('
EOleException %s %x', [E.
Message,E.ErrorCode]));
on E:
Exception do
Writeln(E.Classname, '
:', E.
Message);
end;
end;