Asuntos Oficiales > C/C++
Saber La Ip De Tu Pc
(1/1)
_Viktor:
--- Código: Text --- #include <winsock2.h> // ... void __fastcall TForm1::Button1Click(TObject *Sender) { WORD wVersionRequested; WSADATA wsaData; char name[255]; AnsiString ip; PHOSTENT hostinfo; wVersionRequested = MAKEWORD( 2, 0 ); if ( WSAStartup( wVersionRequested, &wsaData ) == 0 ) { if( gethostname ( name, sizeof(name)) == 0) { Label1->Caption = name; if((hostinfo = gethostbyname(name)) != NULL) { ip = inet_ntoa (*(in_addr *)*hostinfo->h_addr_list); Label2->Caption = ip; } } WSACleanup( ); } }
Autor: RPorcar.-
Saludos!!
Navegación
Ir a la versión completa