Abrufen der MAC-Adresse unter windows in Qt

Ich bin versucht, um die mac-Adresse unter windows xp mit diesem code:

QString getMacAddress()
{
QString macaddress="??:??:??:??:??:??";
#ifdef Q_WS_WIN
PIP_ADAPTER_INFO pinfo=NULL;

unsigned long len=0;
unsigned long nError;

if (pinfo!=NULL)
delete (pinfo);

nError  =   GetAdaptersInfo(pinfo,&len);    //Have to do it 2 times?

if(nError != 0)
{
pinfo= (PIP_ADAPTER_INFO)malloc(len);
nError  =   GetAdaptersInfo(pinfo,&len);
}

if(nError == 0)
macaddress.sprintf("%02X:%02X:%02X:%02X:%02X:%02X",pinfo->Address[0],pinfo->Address[1],pinfo->Address[2],pinfo->Address[3],pinfo->Address[4],pinfo->Address[5]);
#endif
return macaddress;
}

Ist der code wurde hier vorgeschlagen: http://www.qtforum.org/post/42589/how-to-obtain-mac-address.html#post42589

Welche Bibliotheken sollte ich auch machen, damit es funktioniert?.

InformationsquelleAutor Gandalf | 2011-09-30

Schreibe einen Kommentar