注册 登录
编程论坛 Delphi论坛

求助:请问如何获取网址的物理地址(MAC地址)?

桃源书生 发布于 2008-04-09 15:00, 1713 次点击
rt,谢谢!
1 回复
#2
anthony6342008-04-09 18:40
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls,nb30;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
Var
  NCB : TNCB;
  ADAPTER : TADAPTERSTATUS;
  LANAENUM : TLANAENUM;
  intIdx : Integer;
  re : Char;
  buf : String;
begin
  Try
    ZeroMemory(@NCB, SizeOf(NCB));
    NCB.ncb_command := Chr(NCBRESET);
    NCB.ncb_lana_num := LANAENUM.lana[0];
    re := NetBios(@NCB);
    If Ord(re)<>0 Then
      exit;
    ZeroMemory(@NCB, SizeOf(NCB));
    NCB.ncb_command := Chr(NCBASTAT);
    NCB.ncb_lana_num := LANAENUM.lana[0];
    StrPCopy(NCB.ncb_callname, '*');
    NCB.ncb_buffer := @ADAPTER;
    NCB.ncb_length := SizeOf(ADAPTER);
    re := NetBios(@NCB);
    If Ord(re)<>0 Then
      exit;

    buf := '';
    For intIdx := 0 To 5 Do
      buf := buf + InttoHex(Integer(ADAPTER.adapter_address[intIdx]),2)+'-';
    edit1.Text := copy(buf,0,length(buf)-1);
  Finally
  End;

end;

end.
1