cs_othland
Messages postés298Date d'inscriptionjeudi 18 décembre 2003StatutMembreDernière intervention 9 février 2010
-
3 avril 2007 à 10:30
fendatore
Messages postés1Date d'inscriptiondimanche 4 octobre 2009StatutMembreDernière intervention 1 mars 2011
-
1 mars 2011 à 10:44
slt tlm;
j'ai un petit problème, j'utilise une partie de source qui est censée me donner l'adresse physique de ma carte réseau, cette dernière m'est rendue correcte lorsque je suis connecté au réseau local, par contre mon petit programme ne me rend rien lorsque je déconnecte ma carte réseau...
mon code source est 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(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;
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Text:=GetMACAddress;
end;
////////////////
merci pour votre aide!!
Sat83
Messages postés166Date d'inscriptionmardi 11 novembre 2003StatutMembreDernière intervention13 octobre 2008 3 avril 2007 à 14:49
Salut!
J'ai eu le meme probleme y'a quelques semaines, et j'ai toujours pas de reponses malheureusement! J'ai tester plusieurs codes trouvés sur le net mais rien de vraiment efficace...
Si jamais tu trouve quelque chose en tout cas ça m'interresse!
cs_othland
Messages postés298Date d'inscriptionjeudi 18 décembre 2003StatutMembreDernière intervention 9 février 20101 3 avril 2007 à 14:54
salut Sat83
je crois que j'ai trouvé une solution,
tu lances une recherche dans google en tapant "WMI and SMART Component"
et tu télécharge la bibliothèque "Mag WMI"
bonne prog!