unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, NB30;type PASTAT = ^TASTAT; TASTAT = record adapter: TAdapterStatus; name_buf: TNameBuffer; end;type TForm1 = class(TForm) Edit1: TEdit; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}function Getmac: string;var ncb: TNCB; s: string; adapt: TASTAT; lanaEnum: TLanaEnum; i, j, m: integer; strPart, strMac: string;begin FillChar(ncb, SizeOf(TNCB), 0); ncb.ncb_command := Char(NCBEnum); ncb.ncb_buffer := PChar(@lanaEnum); ncb.ncb_length := SizeOf(TLanaEnum); s := Netbios(@ncb); for i := 0 to integer(lanaEnum.Length) - 1 do begin FillChar(ncb, SizeOf(TNCB), 0); ncb.ncb_command := Char(NCBReset); ncb.ncb_lana_num := lanaEnum.lana; Netbios(@ncb); Netbios(@ncb); FillChar(ncb, SizeOf(TNCB), 0); ncb.ncb_command := Chr(NCBAstat); ncb.ncb_lana_num := lanaEnum.lana; ncb.ncb_callname := '* '; ncb.ncb_buffer := PChar(@adapt); ncb.ncb_length := SizeOf(TASTAT); m := 0; if (Win32Platform = VER_PLATFORM_WIN32_NT) then m := 1; if m = 1 then begin if Netbios(@ncb) = Chr(0) then strMac := ''; for j := 0 to 5 do begin strPart := IntToHex(integer(adapt.adapter.adapter_address[j]), 2); strMac := strMac + strPart + '-'; end; SetLength(strMac, Length(strMac) - 1); end; if m = 0 then if Netbios(@ncb) <> Chr(0) then begin strMac := ''; for j := 0 to 5 do begin strPart := IntToHex(integer(adapt.adapter.adapter_address[j]), 2); strMac := strMac + strPart + '-'; end; SetLength(strMac, Length(strMac) - 1); end; end; result := strMac;end;procedure TForm1.Button1Click(Sender: TObject);begin Edit1.Text := Getmac;end;end.