首页  编辑  

远程机器的MAC查询

Tags: /超级猛料/Network.网络通讯/网卡、硬件/   Date Created:

远程机器的MAC查询(For Win2000)

function SendARP(DestIP: DWORD; SrcIP: DWORD; pMacAddr: PDWORD;

 var PhyAddrLen: DWORD): DWORD;

 stdcall; external 'IPHlpAPI.DLL';

function GetRemoteMACAddress(DestIP: string): string;

type

 TInfo = array[0..7] of BYTE;

var

 dwTargetIP: DWORD;

 dwMacAddress: array[0..1] of DWORD;

 dwMacLen: DWORD;

 dwResult: DWORD;

 X: TInfo;

begin

 dwTargetIP := Inet_Addr(PChar(DestIP));

 dwMacLen := 6;

 dwResult := SendARP(dwTargetIP, 0, @dwMacAddress[0], dwMacLen);

 if dwResult = NO_ERROR then

 begin

   X := TInfo(dwMacAddress);

   Result := Format('%x%x%x%x%x%x',

     [X[0], X[1], X[2], X[3], X[4], X[5]]);

 end else Result := SysErrorMessage(dwResult);

end;