Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IP of User 1

Status
Not open for further replies.

lordhaenchen

Programmer
Apr 25, 2001
6
CH
How i can get the IP of the local computeruser?
for computername for exampel it is GetComputerName.
Now the Question is how calls the function for the IP?
Get***
 
Hi

Here is a code that works fine, at least in my hands ...

#include <winsock2.h>

WORD wVersionRequested;
WSADATA wsaData;
char name[255];
PHOSTENT hostinfo;
wVersionRequested = MAKEWORD( 2, 0 );

if ( WSAStartup( wVersionRequested, &wsaData ) == 0 )
{
if( gethostname ( name, sizeof(name)) == 0)
{
// Update Computer Name Edit Box

SetDlgItemText( IDC_NAME, name);

if((hostinfo = gethostbyname(name)) != NULL)
{
m_strIP = inet_ntoa (*(struct in_addr *)*hostinfo->h_addr_list);
}
}

WSACleanup( );
}

// Update TCP/IP Address Edit Box

SetDlgItemText( IDC_ADDRESS, m_strIP);


HTH

Thierry
EMail: Thierry.Marneffe@swing.be
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top