No, he is right :-)

According to my docu:

  Windows NT/2000/XP: Included in Windows NT 4.0 SP4; Windows 2000;
Windows XP Pro; and Windows .NET Server.
  Windows 95/98/Me: Included in Windows 98 and later.
  Header: Declared in Iphlpapi.h.
  Library: Use Iphlpapi.lib.

Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)



-----Original Message-----
From: Willy Denoyette [mailto:[EMAIL PROTECTED]] 
Sent: Montag, 22. April 2002 13:36
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET] Finding out the IP-Address of a PC


Are you sure this works on W98, I could be wrong, but I don't thing the
IP helper library is available on anything less than W2K.

Willy.

----- Original Message -----
From: "Axel Heitland" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, April 22, 2002 1:29 PM
Subject: Re: [DOTNET] Finding out the IP-Address of a PC


Unmanaged, but working:

HTH
        Axel

#include "stdafx.h"
#include <windows.h>
#include <malloc.h>

#include <Iphlpapi.h>
#pragma comment(lib, "Iphlpapi.lib")

void printIPAddresses ()
{
        PMIB_IPADDRTABLE        table;
        DWORD                   size=0;
        GetIpAddrTable( 0, &size, TRUE );

        table = (PMIB_IPADDRTABLE ) alloca( size);

        GetIpAddrTable(
                table,
                &size,
                TRUE );

        for ( int i=0; i<table->dwNumEntries; i++ )
        {
                int ipAdr[4];
                ipAdr[3] = ( table->table[i].dwAddr
) >> 24;
                ipAdr[2] = ( table->table[i].dwAddr & 0xffffff        )
>> 16;
                ipAdr[1] = ( table->table[i].dwAddr & 0xffff  ) >> 8;
                ipAdr[0] = ( table->table[i].dwAddr & 0xff    );

                printf( "%d.%d.%d.%d\n", ipAdr[0], ipAdr[1], ipAdr[2],
ipAdr[3] );
        }

}

int _tmain(int argc, _TCHAR* argv[])
{
        printIPAddresses();
        return 0;
}

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to