You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何获取计算机的品牌及型号信息?

获取Windows电脑品牌与型号(Delphi实现)

要获取如Samsung这类的品牌及型号信息,需要通过**WMI(Windows Management Instrumentation)**读取系统硬件信息,以下是具体的Delphi实现方案:

核心实现代码

uses
  SysUtils, ComObj, ActiveX;

type
  TComputerHardwareInfo = record
    Manufacturer: string; // 品牌厂商
    Model: string;        // 设备型号
  end;

function GetComputerHardwareInfo: TComputerHardwareInfo;
var
  WMIService: OleVariant;
  Items: OleVariant;
  Item: OleVariant;
  Enum: IEnumVariant;
  FetchResult: LongWord;
begin
  // 初始化COM环境
  CoInitialize(nil);
  try
    // 连接本地WMI服务
    WMIService := GetOleObject('winmgmts:\\.\root\CIMV2');
    // 查询Win32_ComputerSystem类,提取品牌和型号字段
    Items := WMIService.ExecQuery('SELECT Manufacturer, Model FROM Win32_ComputerSystem');
    
    Enum := IUnknown(Items._NewEnum) as IEnumVariant;
    if Enum.Next(1, Item, FetchResult) = S_OK then
    begin
      Result.Manufacturer := Trim(Item.Manufacturer);
      Result.Model := Trim(Item.Model);
    end
    else
    begin
      Result.Manufacturer := '未知品牌';
      Result.Model := '未知型号';
    end;
  except
    on E: Exception do
    begin
      Result.Manufacturer := '获取失败: ' + E.Message;
      Result.Model := '';
    end;
  end;
  CoUninitialize;
end;

// 使用示例
procedure TForm1.Button1Click(Sender: TObject);
var
  HardwareInfo: TComputerHardwareInfo;
begin
  HardwareInfo := GetComputerHardwareInfo;
  ShowMessage('品牌: ' + HardwareInfo.Manufacturer + #13#10 + '型号: ' + HardwareInfo.Model);
end;

关键说明

  • 该方案依赖Windows系统内置的WMI服务,Windows XP及以上版本均原生支持,无需额外安装组件。
  • 普通用户权限即可正常获取信息,若出现获取失败,可尝试以管理员身份运行程序,或检查COM组件注册状态。
  • Win32_ComputerSystem类返回的信息直接来自系统硬件注册表项,数据准确性较高。

内容的提问来源于stack exchange,提问作者Pro Boy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 14:01:03