function WMI_Get_Betriebssystem(
const mit_Version:boolean=false):shortstring;
const[INDENT][/INDENT]wbemFlagForwardOnly = $00000020;
var
FSWbemLocator : OLEVariant;
FWMIService : OLEVariant;
FWbemObjectSet: OLEVariant;
FWbemObject : OLEVariant;
oEnum : IEnumvariant;
iValue : LongWord;
begin
Result:='
?';
try
FSWbemLocator := CreateOleObject('
WbemScripting.SWbemLocator');
FWMIService := FSWbemLocator.ConnectServer('
localhost', '
root\CIMV2', '
', '
');
FWbemObjectSet:= FWMIService.ExecQuery('
SELECT Name, Version FROM Win32_OperatingSystem','
WQL',wbemFlagForwardOnly);
oEnum := IUnknown(FWbemObjectSet._NewEnum)
as IEnumVariant;
if oEnum.Next(1, FWbemObject, iValue) = 0
then
begin
result:=String(FWbemObject.
Name);
if Pos('
|',result)>0
then
result:=copy(result,1,Pos('
|',result)-1);
if Pos('
Microsoft ',result)>0
then
Try
result:=trim( copy(result,Pos('
Microsoft ',result)+10,40));
except
end;
if mit_Version
then
begin
result:=result+'
[ '+
String(FWbemObject.Version)+'
]';
end;
FWbemObject:=Unassigned;
end;
except
try
Result:=WMI_Get_Betriebssystem;
except
Result:='
?';
end;
end;
end;