cs_bily
Messages postés40Date d'inscriptionmardi 9 avril 2002StatutMembreDernière intervention 8 novembre 2002
-
31 oct. 2002 à 14:53
ADPro22
Messages postés126Date d'inscriptionmercredi 18 juillet 2001StatutMembreDernière intervention27 octobre 2004
-
4 nov. 2002 à 07:51
Vegeta :-)
salut a tous, je vourdai savoir comment faire en programmation la lecture de l'adresse physique de la carte reseau, lorsqu'on tape "ipconfig / all " sous dos, le resultat a coté de : adresse physique ecrit en hexadecimal
! et surtout si il ya 2 carte comment faire pour lire uniquement celle qu'on veut !
( si vous avez deja un programme qu'il le fait
et qui ecrit le resultat dans un fichier c impeccable
)
ADPro22
Messages postés126Date d'inscriptionmercredi 18 juillet 2001StatutMembreDernière intervention27 octobre 2004 4 nov. 2002 à 07:51
Réponse: C'est possible !
Google est ton ami (et le miens aussi)
Je cite :
--------------------------------------------------------
De :Alex Vinokur (alexvn@bigfoot.com)
Objet :Getting MAC Address (NetBIOS Method) within C/C++-program in Windows2000
This is the only article in this thread
View: Original Format
Groupes de discussion :alt.os.windows2000, comp.os.ms-windows.apps.winsock.misc, comp.os.ms-windows.misc, comp.os.ms-windows.programmer.misc, comp.os.ms-windows.programmer.tools.winsock, microsoft.public.win2000.general
Date :2002-09-04 10:45:20 PST
=============================
Windows 2000 Professional
-------------------
CYGWIN_NT-5
gcc/g++ version 2.95.3-5 (cygwin special)
-------------------
MINGW-1.1
gcc/g++ version 2.95.3-6 (mingw special)
=============================
Here is a program getmac-netbios.cpp "How to Get the Ethernet MAC Address, NetBIOS Method"
from http://tangentsoft.net/wskfaq/examples/getmac-netbios.html P.S. The only line has been added :
cout << "MY INFO : AdapterList.length = " << static_cast(AdapterList.length) << endl;
We can see that AdapterList.length == 0.
So, we can't get MAC address.
Is something wrong ?
P.S.S. The program was running while I was working offline. Is it essential for this program ?
// Get the adapter's info and, if this works, return it in standard,
// colon-delimited form.
if (Netbios(&Ncb) == 0) {
char acMAC[18];
sprintf(acMAC, "%02X:%02X:%02X:%02X:%02X:%02X",
int (Adapter.adapt.adapter_address[0]),
int (Adapter.adapt.adapter_address[1]),
int (Adapter.adapt.adapter_address[2]),
int (Adapter.adapt.adapter_address[3]),
int (Adapter.adapt.adapter_address[4]),
int (Adapter.adapt.adapter_address[5]));
sMAC = acMAC;
return true;
}
else {
char acTemp[80];
ostrstream outs(acTemp, sizeof(acTemp));
outs << "error " << Ncb.ncb_retcode << " on ASTAT" << ends;
sMAC = acTemp;
return false;
}
}
int main()
{
// Get adapter list
LANA_ENUM AdapterList;
NCB Ncb;
memset(&Ncb, 0, sizeof(NCB));
Ncb.ncb_command = NCBENUM;
Ncb.ncb_buffer = (unsigned char *)&AdapterList;
Ncb.ncb_length = sizeof(AdapterList);
Netbios(&Ncb);
// Get all of the local ethernet addresses
string sMAC;
cout << "MY INFO : AdapterList.length = " << static_cast(AdapterList.length) << endl;
for (int i = 0; i < AdapterList.length; ++i) {
if (GetAdapterInfo(AdapterList.lana[i], sMAC)) {
cout << "Adapter " << int (AdapterList.lana[i]) <<
"'s MAC is " << sMAC << endl;
}
else {
cerr << "Failed to get MAC address! Do you" << endl;
cerr << "have the NetBIOS protocol installed?" << endl;
break;
}
} return 0;
}