|
Try
this...
unsigned int
i;
int nRC; WCHAR AdapterName[8192]; // string that contains a list of the network adapters WCHAR *temp, *temp1; char AdapterList[MAX_NUM_ADAPTERS][1024]; char TempAsciiString[8192]; unsigned int AdapterNum = 0; ULONG AdapterLength; memset(AdapterList, 0, (MAX_NUM_ADAPTERS * 1024)
);
memset(AdapterName, 0, sizeof(AdapterName) ); memset(TempAsciiString, 0, sizeof(TempAsciiString) ); //
obtain the name of the adapters installed on this
machine
AdapterLength=4096; i=0;
if(PacketGetAdapterNames((char *)AdapterName, &AdapterLength) == FALSE) { printf("Error: Unable to retrieve the list of the adapters!\n"); exit(-1); } //
The string returned is a multi-byte string on WinNT or later versions of
Windows.
temp = AdapterName; temp1 = AdapterName; while (true) { if( (*temp1 == '\0') && (*(temp1+1) == '\0') ) { // We're at the end of the string. break; } if (*(temp1+1) == '\0') { // Temp1 points to the end of the string. nRC = WideCharToMultiByte(CP_ACP, 0, temp, -1, TempAsciiString, sizeof(TempAsciiString), 0, 0); if (nRC > 0) { memcpy(AdapterList[i], TempAsciiString, (temp1 - temp)+1); } temp = temp1+2; i++; } temp1++; } AdapterNum=i; for (i = 0; i < AdapterNum; i++) { printf("%d- %s\n", i+1, AdapterList[i]); } printf("\n"); David Barnish
|
- [WinPcap-users] retreiving adapter info Annie Deroo
- Re: [WinPcap-users] retreiving adapter info Selcuk Cevher
- Re: [WinPcap-users] retreiving adapter info David Barnish
- Re: [WinPcap-users] retreiving adapter info Annie Deroo
- Re: [WinPcap-users] retreiving adapter info Daniel Frimerman
- RE: [WinPcap-users] retreiving adapter info David Barnish
- Re: [WinPcap-users] retreiving adapter info Annie Deroo
