detecting IP
C / C++ / MFC
3
Posts
3
Posters
0
Views
1
Watching
-
From the Winsock Programmer's FAQ:
http://www.cyberport.com/~tangent/programming/winsock/intermediate.html#getipaddr
Example:
http://www.cyberport.com/~tangent/programming/winsock/examples/ipaddr.html -
void CGetIPDlg::GetIP()
{
WORD wVersionRequested;
WSADATA wsaData;
char name[255];
CString ip;
PHOSTENT hostinfo;
wVersionRequested = MAKEWORD( 2, 0 );if ( WSAStartup( wVersionRequested, &wsaData ) == 0 ) { if( gethostname ( name, sizeof(name)) == 0) { if((hostinfo = gethostbyname(name)) != NULL) { ip = inet\_ntoa (\*(struct in\_addr \*)\*hostinfo->h\_addr\_list); } m\_IP.SetWindowText(ip); UpdateData(FALSE); } WSACleanup( ); }
}
BLaZe
ICQ # 110244345
email : mpblaze@iquebec.com