20.10.2010, 07:14
|
Активный
|
|
Регистрация: 12.09.2008
Сообщения: 391
Репутация: 6078
|
|
Удаленно или локально?
Если удаленно, то так:
Код:
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;
|