Форум: "Система";
Текущий архив: 2004.04.18;
Скачать: [xml.tar.bz2];
ВнизМАС-адрес Найти похожие ветки
← →
Kremen © (2004-02-17 14:28) [0]Подскажите, как узнать МАС-адрес своей сетевой?
← →
Kremen © (2004-02-17 14:28) [1]Я имел в виду програмно узнать
← →
Rouse_ © (2004-02-17 15:18) [2]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, NB30;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function GetMACAdress:String;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TForm1.GetMACAdress:String;
var
NCB : PNCB;
Adapter: PAdapterStatus;
URetCode: Pchar;
RetCode: char;
I: Integer;
Lenum: PlanaEnum;
_SystemID: String;
TMPSTR: String;
begin
Result:="";
_SystemID:="";
Getmem(NCB,sizeof(TNCB));
Fillchar(NCB^,Sizeof(TNCB),0);
Getmem(Lenum,sizeof(TLanaEnum));
Fillchar(Lenum^,Sizeof(TLanaEnum),0);
Getmem(Adapter,sizeof(TAdapterStatus));
Fillchar(Adapter^,Sizeof(TAdapterStatus),0);
Lenum.Length:=chr(0);
NCB.ncb_command:=chr(NCBENUM);
NCB.ncb_buffer:=pointer(Lenum);
NCB.ncb_length:=sizeof(Lenum);
RetCode:=Netbios(NCB);
i:=0;
repeat
Fillchar(NCB^,Sizeof(TNCB),0);
Ncb.ncb_command:= chr(NCBRESET);
Ncb.ncb_lana_num:=lenum.lana[I];
RetCode:= Netbios(Ncb);
Fillchar(NCB^,Sizeof(TNCB),0);
Ncb.ncb_command:= chr(NCBASTAT);
Ncb.ncb_lana_num:= lenum.lana[I];
Ncb.ncb_callname:="* ";
Ncb.ncb_buffer:=pointer(Adapter);
Ncb.ncb_length:=sizeof(TAdapterStatus);
RetCode:= Netbios(Ncb);
if (RetCode=chr(0)) or (RetCode=chr(6)) then begin
_SystemId:=SysUtils.inttohex(ord(Adapter.adapter_address[0]),2)+"-"+
SysUtils.inttohex(ord(Adapter.adapter_address[1]),2)+"-"+
SysUtils.inttohex(ord(Adapter.adapter_address[2]),2)+"-"+
SysUtils.inttohex(ord(Adapter.adapter_address[3]),2)+"-"+
SysUtils.inttohex(ord(Adapter.adapter_address[4]),2)+"-"+
SysUtils.inttohex(ord(Adapter.adapter_address[5]),2);
end;
inc(i);
until (I>=ord(Lenum.length)) or (_SystemID<>"00-00-00-00-00-00");
FreeMem(NCB);
FreeMem(Adapter);
FreeMem(Lenum);
GetMacAdress:=_SystemID;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Caption := GetMACAdress;
end;
end.
Желаю успехов
Страницы: 1 вся ветка
Форум: "Система";
Текущий архив: 2004.04.18;
Скачать: [xml.tar.bz2];
Память: 0.45 MB
Время: 0.037 c