grazie per la vostra risposta.
si avevi ragione con il C non si puo.
ho trovato questo codice che lo fa ma mida solo il mio indirizzo LAN ho compilato questo codice con DEV C++
//inizio codice**********************************
#include <windows.h>
#include <winsock.h>
#include <stdio.h>
char *BinIP2StrIP ( long lnIP)
{
static char s_acStrIP [ 16];
PUCHAR puc = ( unsigned char *) &lnIP;
unsigned int aun [ 4];
for ( int i = 0; i < 4; aun [ i++] = *puc++);
sprintf ( s_acStrIP, "%d.%d.%d.%d", aun [ 0], aun [ 1], aun [ 2], aun [ 3]);
return ( s_acStrIP);
}
char* GetIpAddress()
{
char acClientHost[255];
WORD wVersionRequested;
WSADATA wsaData;
struct hostent *pHostent = NULL;
int nErr = 0;
wVersionRequested = MAKEWORD( 1, 1);
if ( nErr = WSAStartup ( wVersionRequested, &wsaData))
{
// error initializing winsck...
}
if ( nErr = gethostname ( ( char *) acClientHost, sizeof(acClientHost)))
{
return NULL;
}
if (!(pHostent = gethostbyname ( acClientHost)))
{
// an error occured...
return NULL;
}
return BinIP2StrIP ( *(( long *) pHostent->h_addr));
}
int main ()
{
printf("IPAddr: %s\n", GetIpAddress());
return 0;
}
//fine codice***********************************
potete anche provarlo voi fatemi sapere
saluti
|