Thema: MAC-Adresse

Einzelnen Beitrag anzeigen

core

Registriert seit: 26. Dez 2003
Ort: Wadgassen
29 Beiträge
 
#7

Re: MAC-Adresse

  Alt 30. Okt 2005, 14:43
Versuchs mal hiemit:

Delphi-Quellcode:
uses nb30;

function GetAdapterInfo(Lana: Char): string;
var
  Adapter: TAdapterStatus;
  NCB: TNCB;
begin
  FillChar(NCB, SizeOf(NCB), 0);
  NCB.ncb_command := Char(NCBRESET);
  NCB.ncb_lana_num := Lana;
  if Netbios(@NCB) <> Char(NRC_GOODRET) then
  begin
    Result := 'mac not found';
    Exit;
  end;

  FillChar(NCB, SizeOf(NCB), 0);
  NCB.ncb_command := Char(NCBASTAT);
  NCB.ncb_lana_num := Lana;
  NCB.ncb_callname := '*';

  FillChar(Adapter, SizeOf(Adapter), 0);
  NCB.ncb_buffer := @Adapter;
  NCB.ncb_length := SizeOf(Adapter);
  if Netbios(@NCB) <> Char(NRC_GOODRET) then
  begin
    Result := 'mac not found';
    Exit;
  end;
  Result :=
    Format('%X', [Byte(Adapter.adapter_address[0])]) + '-' +
  Format('%X', [Byte(Adapter.adapter_address[1])]) + '-' +
  Format('%X', [Byte(Adapter.adapter_address[2])]) + '-' +
  Format('%X', [Byte(Adapter.adapter_address[3])]) + '-' +
  Format('%X', [Byte(Adapter.adapter_address[4])]) + '-' +
  Format('%X', [Byte(Adapter.adapter_address[5])]);
end;

function GetMACAddress: string;
var
  AdapterList: TLanaEnum;
  NCB: TNCB;
begin
  FillChar(NCB, SizeOf(NCB), 0);
  NCB.ncb_command := Char(NCBENUM);
  NCB.ncb_buffer := @AdapterList;
  NCB.ncb_length := SizeOf(AdapterList);
  Netbios(@NCB);
  if Byte(AdapterList.length) > 0 then
    Result := GetAdapterInfo(AdapterList.lana[0])
  else
    Result := 'mac not found';
end;
Das ganze ist aus Luckies NetWorkInfo (Link) Quelltext!!
  Mit Zitat antworten Zitat