gpt4 book ai didi

c - 从 C 或 Delphi 从 Win32 获取 BIOS UUID

转载 作者:太空狗 更新时间:2023-10-29 15:30:08 44 4
gpt4 key购买 nike

VMWare 配置文件包含这样一行

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

据我所知,大多数(每个?)物理 BIOS 都有这样的 UUID。是否有任何 Windows API 调用来获取此标识符?

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

最佳答案

那个值叫做Universal Unique ID number并且是 SMBIOS 表的一部分,如果您使用 Win32_BIOS WMI 类的 SerialNumber 属性,您将获得与 uuid.bios(来自 vmx 文件)条目相同的 ID 加上前缀 VMware-(示例: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.

如果您想返回不带 VMware- 前缀的相同 uuid,您必须阅读 SMBIOS tables直接(检查系统信息表类型 1 和 UUID 字段),试试这篇文章 Reading the SMBios Tables using Delphi whcih include 有一个示例代码来列出这个值。

UUID格式

来自System Management BIOS (SMBIOS) Reference Specification

UUID 是一种在时间和空间上都具有唯一性的标识符。它不需要中央注册过程。 UUID 的长度为 128 位。它的格式在 RFC 4122 中有描述,但实际的字段内容是不透明的,对 SMBIOS 规范没有意义,它只关心字节顺序。表 10 显示了字段名称;这些字段名称,特别是对于多路复用字段,遵循历史惯例。

enter image description here

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

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

如果全为FFh,则表示该ID当前不存在于系统中,但可以设置。如果该值全为00h,则表示该ID不存在于系统中。

关于c - 从 C 或 Delphi 从 Win32 获取 BIOS UUID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9939725/

44 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com