Ich habe gerade eben was gefunden, versteh aber nicht ganz was der Code macht und wie man ihn anwendet.
Kann es damit funktionieren?
Capo
Delphi-Quellcode:
unit arp;
// (C) 2000 T.Kaluza
interface
uses sysutils,windows, winsock;
type TIPAddr = u_long;
TMACAddr =
array[0..5]
of char;
{$EXTERNALSYM SendArp}
function SendARP (DestIP,SrcIP: TIPAddr;
var TMacAddr: TMACAddr;
var len: u_long): DWORD
stdcall;
function MACtoString(mac: TMACAddr):
string;
procedure getMacbyHost(host:
string;
var mac: TMACAddr);
implementation
const
iphlpapi = '
iphlpapi.dll';
{ Sending an ARP Request }
function sendARP;
external iphlpapi
name '
SendARP';
function MACtoString(mac: TMACAddr):
string;
begin
result:=IntToHex(ord(mac[0]),2)
+IntToHex(ord(mac[1]),2)
+'
.'+IntToHex(ord(mac[2]),2)
+IntToHex(ord(mac[3]),2)+'
.'
+IntToHex(ord(mac[4]),2)
+IntToHex(ord(mac[5]),2);
end;
procedure getMacbyHost(host:
string;
var mac: TMACAddr);
var l: integer;
begin
mac[0]:=#0;
mac[1]:=#0;
mac[2]:=#0;
mac[3]:=#0;
mac[4]:=#0;
mac[5]:=#0;
l:=sizeof(TMACAddr);
sendARP(inet_addr(PChar(host)),inet_addr(PChar('
localhost')),mac,l);
end;
end.