Java编程bios uuid,从Win32的C或德尔福获取BIOS UUID

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"

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

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.

解决方案

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.

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.

UUID Format

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.

yZM0m.png

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.

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.

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值