Hi German!
I have tried with the code, but i get some error like than this :
PIP_ADAPTER_INFO' : undeclared identifier
After that I have added #include Iphlpapi.h with no results
Please, What do you recomend ?
The following code works perfectly with VC7.1:
<code>
#include <winsock2.h>
#include <windows.h>
#include <stdio.h>
#include <Iphlpapi.h>
#pragma comment(lib, "Iphlpapi.lib")
#pragma comment(lib, "wsock32.lib")
void main()
{
ULONG ip;
ULONG buflen;
PIP_ADAPTER_INFO pAdInfo = NULL;
PIP_ADAPTER_INFO pAdInfo_c = NULL;
buflen = 0;
GetAdaptersInfo(pAdInfo, &buflen);
pAdInfo = (struct _IP_ADAPTER_INFO *)new UCHAR[buflen+1];
pAdInfo_c = pAdInfo;
if (GetAdaptersInfo(pAdInfo, &buflen) == ERROR_SUCCESS)
{
do
{
ip = inet_addr(pAdInfo->IpAddressList.IpAddress.String);
if ((ip != 0)&&(ip != 0x7f000001))
{
if (pAdInfo->AddressLength != 0)
{
printf("Adapter-Name: %s\nDescription: %s\nAddress:",
pAdInfo->AdapterName, pAdInfo->Description);
for (int i = 0; i < (int)pAdInfo->AddressLength; i++)
printf(" %02X", pAdInfo->Address
);
printf("\n\n");
}
}
pAdInfo = pAdInfo->Next;
} while (pAdInfo != NULL);
}
delete pAdInfo_c;
}
</code>
If you use VC6 or older, you need to update your PSDK
(or declare the structure by your own, but then I think you also need to
dynamically load the address of the funtions; because you do not have
the correct lib-file)
--
Greetings
Jochen
My blog about Win32 and .NET
http://blog.kalmbachnet.de/