delphi Wmi 获取操作系统信息

uses ActiveX, ComObj;

function GetWMIProperty(WMIProperty: string): string;
var
Wmi, Objs, Obj: OleVariant;
Enum: IEnumVariant;
C: Cardinal;
begin
Wmi:= CreateOleObject(WbemScripting.SWbemLocator);
Objs := Wmi.ConnectServer(.,root/cimv2).ExecQuery(Select * from Win32_OperatingSystem);
Enum := IEnumVariant(IUnknown(Objs._NewEnum));
Enum.Reset;
Enum.Next(1, Obj, C);
Obj := Obj.Properties_.Item(WMIProperty, 0).Value;
Result := Obj;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin

Memo1.Text :=GetWMIProperty(Caption)+GetWMIProperty(Version);
end;

 

delphi Wmi 获取操作系统信息

上一篇:利用Windows自带性能计数器分析软件产品的性能瓶颈(转)


下一篇:Delphi中exit、break、continue等跳出操作的区别(转载)