1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| function GetWMIstring(const WMIClass, WMIProperty:string): string;
const
wbemFlagForwardOnly = $00000020;
var
FWbemObjectSet: OLEVariant;
FWbemObject : OLEVariant;
oEnum : IEnumvariant;
iValue : LongWord;
begin;
Result:='';
try
FWbemObjectSet := FWMIService.ExecQuery(Format('Select %s from %s',
[WMIProperty, WMIClass]),'WQL',wbemFlagForwardOnly);
oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
except
Showmessage('erreur');
Exit;
end;
if oEnum.Next(1, FWbemObject, iValue) = 0 then
if not VarIsNull(FWbemObject.Properties_.Item(WMIProperty).Value) then
Result:=FWbemObject.Properties_.Item(WMIProperty).Value;
FWbemObject := Unassigned; |
Partager