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
showmessage(Format('
Caption %s', [
string(FWbemObject.Caption)]));
showmessage(Format('
Version %s', [
string(FWbemObject.Version)]));
FWbemObject := Unassigned;
end;
end;