5,387
社区成员
发帖
与我相关
我的任务
分享
function GetWMIProperty(WMIType, WMIProperty: string): string;
var Wmi, Objs, Obj: OleVariant;
C: Cardinal;
i,Len:integer;
tempItem:IEnumVariant;
begin
Wmi:= CreateOleObject('WbemScripting.SWbemLocator');
Objs := Wmi.ConnectServer('.','root\cimv2').ExecQuery('Select * from Win32_' + WMIType);
tempItem:=IEnumVariant(IUnknown(Objs._NewEnum));
Result:='';
while (tempItem.Next(1, obj, c) = S_OK) do
begin
Obj := Obj.Properties_.Item(WMIProperty, 0).Value;
if not VarIsNull(obj) then
begin
Result :=Result +trim(Obj);
break;
end;
end;
end;
ShowMessage(GetWMIProperty('BIOS', 'SerialNumber'));
Objs := Wmi.ConnectServer('.','root\cimv2').ExecQuery('Select * from Win32_' + WMIType);
这一行。