您的位置:首页 > 其它

获取MAC地址

2013-12-31 18:46 211 查看
function MacAddress: string;

var

Lib: Cardinal;

Func: function(GUID: PGUID): Longint; stdcall;

GUID1, GUID2: TGUID;

begin

Result := '';

Lib := LoadLibrary('rpcrt4.dll');

if Lib <> 0 then

begin

if Win32Platform <> VER_PLATFORM_WIN32_NT then

@Func := GetProcAddress(Lib, 'UuidCreate')

else @Func := GetProcAddress(Lib, 'UuidCreateSequential');

if Assigned(Func) then

begin

if (Func(@GUID1) = 0) and

(Func(@GUID2) = 0) and

(GUID1.D4[2] = GUID2.D4[2]) and

(GUID1.D4[3] = GUID2.D4[3]) and

(GUID1.D4[4] = GUID2.D4[4]) and

(GUID1.D4[5] = GUID2.D4[5]) and

(GUID1.D4[6] = GUID2.D4[6]) and

(GUID1.D4[7] = GUID2.D4[7]) then

begin

Result :=

IntToHex(GUID1.D4[2], 2) + '-' +

IntToHex(GUID1.D4[3], 2) + '-' +

IntToHex(GUID1.D4[4], 2) + '-' +

IntToHex(GUID1.D4[5], 2) + '-' +

IntToHex(GUID1.D4[6], 2) + '-' +

IntToHex(GUID1.D4[7], 2);

end;

end;

FreeLibrary(Lib);

end;

end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: