MAC Adresse

Résolu
michelroc Messages postés 84 Date d'inscription lundi 19 mai 2003 Statut Membre Dernière intervention 2 janvier 2010 - 1 mars 2007 à 19:58
cs_Kenavo Messages postés 702 Date d'inscription vendredi 21 mars 2003 Statut Membre Dernière intervention 1 octobre 2009 - 2 mars 2007 à 08:21
Bonjour,

Je recherche ou faire( delphi) un programme qui tourne sous DOS. Permettant de me donner la MAC Adresse.

Merci

Michel [:)]

7 réponses

PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
1 mars 2007 à 20:10
salut,
donc ta demande...
la permission? accordée...

précise ton problème à un certain niveau de code, là où tu bloques...

<hr size="2" width="100%" />Prenez un instant pour répondre à [infomsg_SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp
3
japee Messages postés 1727 Date d'inscription vendredi 27 décembre 2002 Statut Modérateur Dernière intervention 6 novembre 2021 8
1 mars 2007 à 20:11
Salut,


C'est l'exemple même de code qui ne pose aucun problème, et qui est largement répandu sur le net.

Comment obtenir l'adresse MAC d'une carte réseau
0
michelroc Messages postés 84 Date d'inscription lundi 19 mai 2003 Statut Membre Dernière intervention 2 janvier 2010
1 mars 2007 à 21:20
Ci dessous ce que j'ai recupere sur ce site mais je ne sais pas afficher le resultat sous DOS  ??  soyer indulgent . Merci

program Project2;


{$APPTYPE CONSOLE}


uses
  SysUtils,
  NB30;


{ TODO -oUser -cConsole Main : placez le code ici }


  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 :=
    IntToHex(Byte(Adapter.adapter_address[0]), 2) + '-' +
    IntToHex(Byte(Adapter.adapter_address[1]), 2) + '-' +
    IntToHex(Byte(Adapter.adapter_address[2]), 2) + '-' +
    IntToHex(Byte(Adapter.adapter_address[3]), 2) + '-' +
    IntToHex(Byte(Adapter.adapter_address[4]), 2) + '-' +
    IntToHex(Byte(Adapter.adapter_address[5]), 2);
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;


end.
Michel [:)]
0
Utilisateur anonyme
1 mars 2007 à 22:47
Tu as totalement raison PCPT :

Il y a aussi une source ici : http://herea.soft.free.fr/Samples.htm. Si je me rappelle bien elle ne fonctionne que sous Win95/98 mais est tres simple. Sinon une autre alternative est de réaliser un pipe http://delphi.developpez.com/faq/?page=applisconsole : Là c'est de la haulte voltige.

@+
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Cirec Messages postés 3833 Date d'inscription vendredi 23 juillet 2004 Statut Modérateur Dernière intervention 18 septembre 2022 50
1 mars 2007 à 23:05
Salut,

je ne pense pas qu'il soit utile de réaliser un pipe sur une application console

program Project2; {$APPTYPE CONSOLE}

uses

il suffit d'utiliser Write où Writeln en lui passant la valeur de retour de GetMACAddress pour voir s'afficher le résultat dans une fenêtre dos

 
@+
Cirec

<hr size="2" />
0
japee Messages postés 1727 Date d'inscription vendredi 27 décembre 2002 Statut Modérateur Dernière intervention 6 novembre 2021 8
2 mars 2007 à 00:02
Oui, Cirec, c'est si simple...
à condition d'être familier des applications console.

Ce qui n'est d'ailleurs pas mon cas...
Mais en bidouillant un peu, on y finit par y arriver.
Il faut seulement en intégrer la philosophie, et apprendre à se servir des basiques "WriteLn" et "ReadLn".
Allez, Michel, je te le mets dans le contexte :

program McAdress;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  Windows,
  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 := '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 := 'not found';
    Exit;
  end;
  Result :=
    IntToHex(Byte(Adapter.adapter_address[0]), 2) + '-' +
    IntToHex(Byte(Adapter.adapter_address[1]), 2) + '-' +
    IntToHex(Byte(Adapter.adapter_address[2]), 2) + '-' +
    IntToHex(Byte(Adapter.adapter_address[3]), 2) + '-' +
    IntToHex(Byte(Adapter.adapter_address[4]), 2) + '-' +
    IntToHex(Byte(Adapter.adapter_address[5]), 2);
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;

begin
  WriteLn('Adresse Mac : ' + GetMACAddress);
  ReadLn;
end.

Elle est pas belle, la vie ?
0
cs_Kenavo Messages postés 702 Date d'inscription vendredi 21 mars 2003 Statut Membre Dernière intervention 1 octobre 2009 5
2 mars 2007 à 08:21
I' sont bien les nouveaux admins ! Non ?






Ken@vo




<hr size="2" width="100%" />



Code, Code, Codec !






[%3C/body
]
0
Rejoignez-nous