Можно еще проще, если работает под NT
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Winsock, ExtCtrls;
const
MAX_ADAPTER_ADDRESS_LENGTH = 6;
type
TMacAddress = array[0..MAX_ADAPTER_ADDRESS_LENGTH - 1] of byte;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
end;
function SendARP(const DestIP, SrcIP: ULONG;
pMacAddr: PULONG; var PhyAddrLen: ULONG): DWORD; stdcall; external 'IPHLPAPI.DLL';
var
Form1: TForm1;
implementation
procedure TForm1.Button1Click(Sender: TObject);
function GetMAC(Value: TMacAddress; Length: DWORD): String;
var
I: Integer;
begin
if Length = 0 then Result := '00-00-00-00-00-00' else
begin
Result := '';
for i:= 0 to Length - 2 do
Result := Result + IntToHex(Value[i], 2) + '-';
Result := Result + IntToHex(Value[Length-1], 2);
end;
end;
var
DestIP, SrcIP: ULONG;
pMacAddr: TMacAddress;
PhyAddrLen: ULONG;
begin
DestIP := inet_addr('195.182.10.22');
PhyAddrLen := 6;
SendArp(DestIP, 0, @pMacAddr, PhyAddrLen);
Caption := GetMAC(pMacAddr, PhyAddrLen);
end;
end.