----- Original Message -----
Sent: Monday, June 30, 2003 4:03 PM
Subject: RE: [WinPcap-users] retreiving
adapter info
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
-----Original Message-----
From: Annie Deroo
[mailto:[EMAIL PROTECTED]
Sent: Sunday, June 29, 2003 8:21
AM
To: [EMAIL PROTECTED]
Subject:
[WinPcap-users] retreiving adapter info
How can I get a list of my adapters? I know the
function PacketGetAdapterNames gives me all the adapters on my computers,
but how do I show information about them in a Visual C++ program? Functions
like wprintf(L"\n%d- %s\n",i+1,AdapterList[i]) (output = 7) and
printf("\n%d- %s\n",i+1,AdapterList[i]) (error when running) can't be used
to put a CString in a list or in a messagebox! The compiler says: left of
'.SymbolicLink' must have class/struct/union type, when I use the
SymbolicLink part of the adapters. In my program I want to show info about
the available adapters in a list and let the user select one. I'm sure this
is done before in Visual C++, so if somebody knows how I could do that or
knows where I can find code that does that, let me know. Thank
U