Delphi编程通过IP取MAC地址的方法

减小字体 增大字体 作者:佚名  来源:转载  发布时间:2011-02-18 13:00:08

uses
  WinSock;

Function sendarp(ipaddr: ulong; temp: dword; ulmacaddr: pointer;
  ulmacaddrleng: pointer): dword; StdCall;
External 'Iphlpapi.dll' Name 'SendARP';

procedure TForm1.Button1Click(Sender: TObject);
var
  myip: ulong;
  mymac: array [0 .. 5] of byte;
  mymaclength: ulong;
  r: integer;
begin
  myip := inet_addr(PChar('192.168.6.180'));
  mymaclength := length(mymac);
  r := sendarp(myip, 0, @mymac, @mymaclength);
  label1.caption := 'errorcode:' + inttostr(r);
  label2.caption := 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]]);
end;

Tags:

作者:佚名
  • 好的评价 如果您觉得此文章好,就请您
      0%(0)
  • 差的评价 如果您觉得此文章差,就请您
      0%(0)

文章评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论

广告位置B