IP Address
-
go to www.whatismyipaddress.com to see it at once. includeh10
-
go to www.whatismyipaddress.com to see it at once. includeh10
includeh10 wrote:
go to www.whatismyipaddress.com to see it at once.
This will give you the public ip if you are behind a proxy.
-Prakash
-
The best way to grab a list of all the ip addresses attached to your local system is using the IPHelper[^] library. You'll need to include the
IPHlpApi.h
andwinsock2.h
header files, then addiphlpapi.lib
andws2_32.lib
to your list of import libraries.MIB_IPADDRTABLE *pIPAddrTable = NULL;
DWORD dwSize = 0;
DWORD dwRetVal = 0;if (GetIpAddrTable(pIPAddrTable, &dwSize, 0) != ERROR_INSUFFICIENT_BUFFER )
{
printf( "Error getting buffer size." );
}
else
{
pIPAddrTable = ( MIB_IPADDRTABLE * ) malloc ( dwSize );if ( (dwRetVal = GetIpAddrTable( pIPAddrTable, & dwSize, 0 ) ) != NO\_ERROR ) { printf("GetIpAddrTable failed.\\n"); } for( int i = 0; i < pIPAddrTable->dwNumEntries; i ++ ) { in\_addr add; in\_addr subnet; ZeroMemory( & add, sizeof( in\_addr ) ); ZeroMemory( & subnet, sizeof( in\_addr ) ); add.S\_un.S\_addr = pIPAddrTable->table\[ i \].dwAddr; subnet.S\_un.S\_addr = pIPAddrTable->table\[i\].dwMask; printf("IP Address: %s\\n", inet\_ntoa( add ) ); printf("IP Mask: %s\\n\\n", inet\_ntoa( subnet ) ); } free( pIPAddrTable );
}
Gavin Taylor w: http://www.gavspace.com -- modified at 12:11 Sunday 1st January, 2006
-
go to www.whatismyipaddress.com to see it at once. includeh10
-
Open a command window. go to Start->Run, type in "cmd" and click OK In Command window type in "ipconfig" click ENTER key You can see the IP address here.
-
Open a command window. go to Start->Run, type in "cmd" and click OK In Command window type in "ipconfig" click ENTER key You can see the IP address here.
-
The best way to grab a list of all the ip addresses attached to your local system is using the IPHelper[^] library. You'll need to include the
IPHlpApi.h
andwinsock2.h
header files, then addiphlpapi.lib
andws2_32.lib
to your list of import libraries.MIB_IPADDRTABLE *pIPAddrTable = NULL;
DWORD dwSize = 0;
DWORD dwRetVal = 0;if (GetIpAddrTable(pIPAddrTable, &dwSize, 0) != ERROR_INSUFFICIENT_BUFFER )
{
printf( "Error getting buffer size." );
}
else
{
pIPAddrTable = ( MIB_IPADDRTABLE * ) malloc ( dwSize );if ( (dwRetVal = GetIpAddrTable( pIPAddrTable, & dwSize, 0 ) ) != NO\_ERROR ) { printf("GetIpAddrTable failed.\\n"); } for( int i = 0; i < pIPAddrTable->dwNumEntries; i ++ ) { in\_addr add; in\_addr subnet; ZeroMemory( & add, sizeof( in\_addr ) ); ZeroMemory( & subnet, sizeof( in\_addr ) ); add.S\_un.S\_addr = pIPAddrTable->table\[ i \].dwAddr; subnet.S\_un.S\_addr = pIPAddrTable->table\[i\].dwMask; printf("IP Address: %s\\n", inet\_ntoa( add ) ); printf("IP Mask: %s\\n\\n", inet\_ntoa( subnet ) ); } free( pIPAddrTable );
}
Gavin Taylor w: http://www.gavspace.com -- modified at 12:11 Sunday 1st January, 2006
Hi, This works for me,
CString sLocalIp; HOSTENT *hs = NULL; UCHAR ch[4] = {0}; CHAR szHostName[50]={0}; // get name of machine if ( SOCKET_ERROR == ::gethostname((LPSTR)(LPCTSTR)szHostName, 50) ) { return GetLastError(); } hs = gethostbyname((LPSTR)(LPCTSTR)szHostName); if ( hs == NULL ) { return GetLastError(); } // h_addr contains ip address memcpy(ch, hs->h_addr,4); // form string sLocalIp.Format("%d.%d.%d.%d", ch[0], ch[1], ch[2], ch[3]);
Hope this is also correct method.(((??))) Jetli Constant Thing In World Is Change. -
mehrdadov wrote:
I want to get my Computer IP.How can I do it?
gethostbyaddr
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV
-
Hi, This works for me,
CString sLocalIp; HOSTENT *hs = NULL; UCHAR ch[4] = {0}; CHAR szHostName[50]={0}; // get name of machine if ( SOCKET_ERROR == ::gethostname((LPSTR)(LPCTSTR)szHostName, 50) ) { return GetLastError(); } hs = gethostbyname((LPSTR)(LPCTSTR)szHostName); if ( hs == NULL ) { return GetLastError(); } // h_addr contains ip address memcpy(ch, hs->h_addr,4); // form string sLocalIp.Format("%d.%d.%d.%d", ch[0], ch[1], ch[2], ch[3]);
Hope this is also correct method.(((??))) Jetli Constant Thing In World Is Change.The problem with that method is that it will only pullback one IP, the question was how do you retrieve the IP address for my local computer, it's quite possible to have several NIC's all with several IP addresses. The server sitting under my desk has 3 different IP's for instance. But yeah, your way does work aswell :) Gavin Taylor w: http://www.gavspace.com -- modified at 7:59 Monday 2nd January, 2006
-
The problem with that method is that it will only pullback one IP, the question was how do you retrieve the IP address for my local computer, it's quite possible to have several NIC's all with several IP addresses. The server sitting under my desk has 3 different IP's for instance. But yeah, your way does work aswell :) Gavin Taylor w: http://www.gavspace.com -- modified at 7:59 Monday 2nd January, 2006
Thats True Many thanks Gavin. :-D Jetli Constant Thing In World Is Change.