Mail sent : 6/22/2005
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 ?
Thanks in advanced,
German
Jochen Kalmbach [MVP] - 06 Jul 2005 18:10 GMT
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 ?
See: GetAdaptersInfo
http://msdn.microsoft.com/library/en-us/iphlp/iphlp/getadaptersinfo.asp
<quote>
Requires Windows XP, Windows 2000 Professional, Windows Me, or Windows 98
</quote>
See: Using the Windows Headers
http://msdn.microsoft.com/library/en-us/winprog/winprog/using_the_windows_headers.asp
In short: you need to define _WIN32_WINNT and WINVER with the correct
values, befor including the h-file.
See also: How To Get the MAC Address for an Ethernet Adapter
http://support.microsoft.com/default.aspx?scid=kb;en-us;118623

Signature
Greetings
Jochen
My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Jochen Kalmbach [MVP] - 06 Jul 2005 19:47 GMT
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[i]);
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)

Signature
Greetings
Jochen
My blog about Win32 and .NET
http://blog.kalmbachnet.de/
German - 06 Jul 2005 20:22 GMT
Hi Jochen :
How is in the case of VC++6.00 ?
German
> Hi German!
>
[quoted text clipped - 53 lines]
> dynamically load the address of the funtions; because you do not have
> the correct lib-file)
German - 06 Jul 2005 22:42 GMT
And aditional question:
#include <Iphlpapi.h> only works in VC7.0?
Is possible to download file and then I add it to the proyect in VC6.0?
Thanks again.
> Hi Jochen :
>
[quoted text clipped - 59 lines]
> > dynamically load the address of the funtions; because you do not have
> > the correct lib-file)
Nishant Sivakumar - 07 Jul 2005 05:03 GMT
See http://www.voidnish.com/articles/ShowArticle.aspx?code=MacIdChanger
(comes with full source code)

Signature
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
> Mail sent : 6/22/2005
>
[quoted text clipped - 8 lines]
>
> German
German - 07 Jul 2005 18:03 GMT
Ok Nishant, I have reviewed the code and I found that #include Iphlpapi.h
it's a main requirement to implement the proyect; how I did not have it,then
I have downloaded VCToolKitSetup, and after that I just found that file.
I have included it in the same code (lines below) but the new problem is
GetAdaptersInfo' : undeclared identifier
What is the next step?
Thanks in advanced,
German Medina
++++++++++++++++++++++++++++++++++++++++++++++++++++
> See http://www.voidnish.com/articles/ShowArticle.aspx?code=MacIdChanger
> (comes with full source code)
[quoted text clipped - 11 lines]
> >
> > German
Nishant Sivakumar - 08 Jul 2005 05:37 GMT
Could you build my sample project? If not, it's possible that your include
directories are not setup properly.

Signature
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
> Ok Nishant, I have reviewed the code and I found that #include Iphlpapi.h
> it's a main requirement to implement the proyect; how I did not have
[quoted text clipped - 26 lines]
>> >
>> > German
German - 08 Jul 2005 18:30 GMT
Nishant :
Would you point me out how can I set up the include directories ?
Because, When I have downloaded VCToolKitSetup, Iphlpapi.h was saved in a
different directory than //Microsoft Visual Studio/VC98/MFC/Incude, I had
copied Iphlpapi.h to //Microsoft Visual Studio/VC98/MFC/Incude.
I guess, here is the problem. What do you think ?
German Medina
+519-662-850
......................................................................................
> Could you build my sample project? If not, it's possible that your include
> directories are not setup properly.
[quoted text clipped - 29 lines]
> >> >
> >> > German
Nishant Sivakumar - 11 Jul 2005 12:31 GMT
Uhm, copying files from a newer PSDK into an existing one is not a good
idea. You'll end up with a bunch of header files that aren't matched.
You seem to be using VC++ 6. Go to Tools-Options-Directories. You can
set/change the search order there.

Signature
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
> Nishant :
>
[quoted text clipped - 47 lines]
>> >> >
>> >> > German