从Win32获取C或Delphi的BIOS UUID [英] Get BIOS UUID from C or Delphi from Win32

查看:612
本文介绍了从Win32获取C或Delphi的BIOS UUID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VMWare配置文件包含一行,如

VMWare configuration files contains a line like

uuid.bios = "56 4d ed cf 3c cd 63 20-53 78 95 86 26 92 22 c8"

最多(每个?)物理BIOS有这样一个UUID。有没有Windows API调用来获取此标识符?

And afaik most (every?) physical BIOS has such an UUID. Is there any Windows API call to get this identifier?

我尝试过WMI类Win32_ComputerSystemProduct.UUID属性,但该值与uuid.bios值不同。 HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\MachineGuid的值也是不同的。

I've tried the WMI class Win32_ComputerSystemProduct.UUID property but the value is different from the uuid.bios value. The value of HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\MachineGuid is different, too.

推荐答案

该值被称为 通用唯一身份证号码 ,并且是SMBIOS表的一部分,如果您使用Win32_BIOS WMI类的SerialNumber属性,您将获得与 uuid.bios (从vmx文件)条目加上前缀 VMware - (示例: VMware-56 4d af ac d8 bd 4d 2c-06 df ca af 89 71 44 93

That value is called Universal Unique ID number and is part of the SMBIOS tables, if you use the SerialNumber property of the Win32_BIOS WMI class youu will get the same id of the uuid.bios (from the vmx file) entry plus the prefix VMware- (example : VMware-56 4d af ac d8 bd 4d 2c-06 df ca af 89 71 44 93)

uses
  SysUtils,
  ActiveX,
  ComObj,
  Variants;

// The Win32_BIOS class represents the attributes of the computer system's basic input/output services (BIOS) that are installed on the computer.

procedure  GetWin32_BIOSInfo;
const
  WbemUser            ='';
  WbemPassword        ='';
  WbemComputer        ='localhost';
  wbemFlagForwardOnly = $00000020;
var
  FSWbemLocator : OLEVariant;
  FWMIService   : OLEVariant;
  FWbemObjectSet: OLEVariant;
  FWbemObject   : OLEVariant;
  oEnum         : IEnumvariant;
  iValue        : LongWord;
begin;
  FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
  FWMIService   := FSWbemLocator.ConnectServer(WbemComputer, 'root\CIMV2', WbemUser, WbemPassword);
  FWbemObjectSet:= FWMIService.ExecQuery('SELECT SerialNumber FROM Win32_BIOS','WQL',wbemFlagForwardOnly);
  oEnum         := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
  if oEnum.Next(1, FWbemObject, iValue) = 0 then
    Writeln(Format('SerialNumber    %s',[String(FWbemObject.SerialNumber)]));// String
end;


begin
 try
    CoInitialize(nil);
    try
      GetWin32_BIOSInfo;
    finally
      CoUninitialize;
    end;
 except
    on E:EOleException do
        Writeln(Format('EOleException %s %x', [E.Message,E.ErrorCode])); 
    on E:Exception do
        Writeln(E.Classname, ':', E.Message);
 end;
 Writeln('Press Enter to exit');
 Readln;      
end.

如果您希望返回相同的uuid而不使用 VMware - 前缀,您必须直接阅读 SMBIOS表(请查看系统信息表格1和UUID字段),请尝试此文章 使用Delphi读取SMBios表 包含一个示例代码以列出此值。

If you want return the same uuid without the VMware- prefix you must read the SMBIOS tables directly (check the System Information table type 1 and the UUID field), try this article Reading the SMBios Tables using Delphi whcih include has a sample code to list this value.

系统管理BIOS(SMBIOS)参考规范

UUID是一个标识符这被设计为在时间和空间上都是独一无二的。它不需要中央注册过程。 UUID长128位。其格式在RFC 4122中描述,但是实际的字段内容是不透明的,对于SMBIOS规范而言并不重要,SMBIOS规范仅涉及字节顺序。表10显示了字段名称;这些字段名称,特别是多路复用字段,遵循历史实践。

A UUID is an identifier that is designed to be unique across both time and space. It requires no central registration process. The UUID is 128 bits long. Its format is described in RFC 4122, but the actual field contents are opaque and not significant to the SMBIOS specification, which is only concerned with the byte order. Table 10 shows the field names; these field names, particularly for multiplexed fields, follow historical practice.

尽管RFC 4122建议所有字段的网络字节顺序,PC行业(包括ACPI,UEFI和Microsoft规范)始终如一对于前三个字段使用小端字节编码:time_low,time_mid,time_hi_and_version。 UUID的SMBIOS表示也应该使用相同的编码,也称为有线格式。

Although RFC 4122 recommends network byte order for all fields, the PC industry (including the ACPI, UEFI, and Microsoft specifications) has consistently used little-endian byte encoding for the first three fields: time_low, time_mid, time_hi_and_version. The same encoding, also known as wire format, should also be used for the SMBIOS representation of the UUID.

UUID {00112233-4455-6677-8899-AABBCCDDEEFF}因此将被表示为:
33 22 11 00 55 44 77 66 88 99 AA BB CC DD EE FF。

The UUID {00112233-4455-6677-8899-AABBCCDDEEFF} would thus be represented as: 33 22 11 00 55 44 77 66 88 99 AA BB CC DD EE FF.

如果值都是FFh,系统当前不存在ID,但可以设置。如果值为00h,系统中不存在该ID。

If the value is all FFh, the ID is not currently present in the system, but it can be set. If the value is all 00h, the ID is not present in the system.

这篇关于从Win32获取C或Delphi的BIOS UUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆