1,593
社区成员
发帖
与我相关
我的任务
分享
Function sendarp(ipaddr:ulong;temp:dword;ulmacaddr:pointer;ulmacaddrleng:pointer):DWord; StdCall; External 'Iphlpapi.dll' Name 'SendARP';
function Ip2Mac(ip:string):string;
var
myip:ulong;
mymac:array[0..5] of byte;
mymaclength:ulong;
r:integer;
begin
Result := '';
myip := inet_addr(PChar(ip));
if myip<>ulong(INADDR_NONE) then
begin
mymaclength := length(mymac);
r:=sendarp(myip,0,@mymac,@mymaclength);
if r=0 then
begin
Result := format('%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x',[mymac[0],mymac[1],mymac[2],mymac[3],mymac[4],mymac[5]]);
end;
end;
end;