W
wrnxd168
Unregistered / Unconfirmed
GUEST, unregistred user!
function GetMacFromIP(Ip: string): string;
Function sendarp(ipaddr:ulong;
temp:dword;
ulmacaddrointer;
ulmacaddrlengointer) : DWord;
StdCall;
External 'Iphlpapi.dll' Name 'SendARP';
function GetMacFromIP(Ip:string):string;
var
myip:ulong;
mymac:array[0..5] of byte;
mymaclength:ulong;
r:integer;
begin
myip:=inet_addr(PChar(ip));
mymaclength:=length(mymac);
r:=sendarp(myip,0,@mymac,@mymaclength);
if r=0 then
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]])
else
result:='offline';
end;
如上,发现不在线的机器返回的mac地址全是0000.0000.0ffe,为什么呢,
SENDARP返回值都是什么呀?
Function sendarp(ipaddr:ulong;
temp:dword;
ulmacaddrointer;
ulmacaddrlengointer) : DWord;
StdCall;
External 'Iphlpapi.dll' Name 'SendARP';
function GetMacFromIP(Ip:string):string;
var
myip:ulong;
mymac:array[0..5] of byte;
mymaclength:ulong;
r:integer;
begin
myip:=inet_addr(PChar(ip));
mymaclength:=length(mymac);
r:=sendarp(myip,0,@mymac,@mymaclength);
if r=0 then
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]])
else
result:='offline';
end;
如上,发现不在线的机器返回的mac地址全是0000.0000.0ffe,为什么呢,
SENDARP返回值都是什么呀?