マックアドレス取得方法を調べていたら以下のような方法を発見したのですが使用方法がわかりません、Functionとなっているのですがコレを用いFORM1のEdit1の中に代入したいと思います。
方法を教えていただきたいです。
Uses Winsock;
Function SendARP (DestIp: DWORD; srcIP: DWORD; pMacAddr: pointer; PhyAddrLen: Pointer): DWORD;stdcall; external 'iphlpapi.dll';
Function getRemoteMacAdress (var address: String): Boolean;
var
dwRemoteIP: DWORD;
PhyAddrLen: Longword;
pMacAddr : array [0..1] of Longword;
temp: array [0..5] of byte;
I: Byte;
begin
Result := false;
dwremoteIP := inet_addr (@address[1]);
if dwremoteIP <> 0 then begin
PhyAddrLen := 6;
if SendARP (dwremoteIP, 0, @pMacAddr, @PhyAddrLen) = NO_ERROR then begin
if (PhyAddrLen <> 0) and (pMacAddr[0] <> 0) then begin
Move (pMacAddr, temp, 6);
address := '';
For I := 0 to 5 do address := address + inttohex (temp[i], 2)+'-';
Delete (address, Length (address), 1);
Result := true;
end;
end;
end;
end;
自己解決いたしました。
ツイート | ![]() |