delphi Wmi 获取操作系统信息


本文整理自网络,侵删。

 


unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

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;

end.

相关阅读 >>

Delphi pagecontrol不�@示tab方式

Delphi 中相对路径与绝对路径、系统环境变量等相关函数说明

Delphi连接mysql出现乱码

Delphi settimer 用法

Delphi program name、process id、window handle、process handle 的转换函数

Delphi 调试ios时出现 please specify exact device preset uuid

Delphi tradiogroup 单选分组框组件

Delphi 使用钩子函数

Delphi xe5 安卓设置屏幕横屏竖屏

Delphi 分解时间 �cdecodedate、decodetime … decodedatetime …

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...