mac adresse auslesen...
-
hallo,ich nutze vs 2008
#include "Iphlpapi.h"
Mein Knopf:
// Get the buffer length required for IP_ADAPTER_INFO. ULONG BufferLength = 0; BYTE* pBuffer = 0; if( ERROR_BUFFER_OVERFLOW == GetAdaptersInfo( 0, &BufferLength )) { // Now the BufferLength contain the required buffer length. // Allocate necessary buffer. pBuffer = new BYTE[ BufferLength ]; } else { // Error occurred. handle it accordingly. } // Get the Adapter Information. PIP_ADAPTER_INFO pAdapterInfo = reinterpret_cast<PIP_ADAPTER_INFO>(pBuffer); GetAdaptersInfo( pAdapterInfo, &BufferLength ); // Iterate the network adapters and print their MAC address. while( pAdapterInfo ) { // Assuming pAdapterInfo->AddressLength is 6. CString csMacAddress; csMacAddress.Format(_T("%02x:%02x:%02x:%02x:%02x:%02x"), pAdapterInfo->Address[0], pAdapterInfo->Address[1], pAdapterInfo->Address[2], pAdapterInfo->Address[3], pAdapterInfo->Address[4], pAdapterInfo->Address[5]); cout << "Adapter Name :" << pAdapterInfo->AdapterName << " " << "MAC :" << (LPCTSTR) csMacAddress << endl; // Get next adapter info. pAdapterInfo = pAdapterInfo->Next; } // deallocate the buffer. delete[] pBuffer;
error LNK2019: unresolved external symbol _GetAdaptersInfo@8 referenced in function "public: void __thiscall CmacDlg::OnBnClickedCancel(void)" (?OnBnClickedCancel@CmacDlg@@QAEXXZ)
laut tut soll ich die lphlpapi.lib einbinden:
[/cpp]
#pragma comment(lib,"lphlpapi.lib")
[cpp]LINK : fatal error LNK1104: cannot open file 'lphlpapi.lib'
die windows suche brachte auch keine lphlpapi.lib
-
Also wenn du statt einem kleinen "l" ein großes "I" am Anfang des Dateinamens der Lib schreibst, dann wird das der Linker auch finden.
-
verdammt !!! Du hast recht
thx