- 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;
Delphi 获取Mac地址
最新推荐文章于 2025-05-17 13:27:33 发布
本文介绍了一种使用Delphi通过调用Windows API来获取计算机MAC地址的方法。该方法利用了RPC库中的UuidCreate函数生成全局唯一标识符,并通过比较特定字节来间接获取MAC地址的后六位。
423

被折叠的 条评论
为什么被折叠?



