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

查看:1943
本文介绍了从Win32的C或德尔福获取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"

和AFAIK最多(每?)物理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 \\软件的价值\\微软\\加密\\ 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.

推荐答案

这值被称为的 通用唯一ID号 是SMBIOS表中的一部分,如果你使用Win32_BIOS WMI类的SerialNumber属性youu会得到的相同的ID在 uuid.bios (从VMX文件)项加preFIX 的VMware - (例如:的VMware-56 4D AF交流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 - preFIX必须阅读的 SMBIOS表直接(检查系统信息表1型和UUID场),尝试本文的 阅读使用SMBIOS表德尔福 whcih包括有一个样本code列出此值。

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规范,这是只关心的字节顺序不显著。表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,微软规格)一贯使用little-endian字节编码的前三个领域:time_low,time_mid,time_hi_and_version。相同的编码,也被称为传输格式,也应使用的UUID的SMBIOS重新presentation

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}将因此被重新presented为:
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不是当前present在系统中,但它可以被设置。如果该值是所有00h时,该ID是不是在系统present

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或德尔福获取BIOS UUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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