永发信息网

Delphi获取本地连接的MAC地址,怎么获取

答案:1  悬赏:30  手机版
解决时间 2021-02-15 12:02
  • 提问者网友:疯子也有疯子的情调
  • 2021-02-14 15:35
Delphi获取本地连接的MAC地址,怎么获取
最佳答案
  • 五星知识达人网友:你哪知我潦倒为你
  • 2021-02-14 16:26
Delphi获取本机MAC地址方法:
  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;
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯