hello tout le monde, bon voila j'ai un petit probleme, j'essay de recuperer le nom de ma machine par Winsock (si vous connaisez un proceder plus simple je suis preneur)
donc reprenont, je fait :
#include <winsock2.h>
#pragma comment(lib, "ws2_32.lib")
#include <stdio.h>
void main()
{
WSADATA WSAData;
WSAStartup(MAKEWORD(2,0), &WSAData);
SOCKET sock;
SOCKADDR_IN sin;
char *buffer = new char[255];
char * name = new char[255];
/* Tout est configuré pour se connecter sur IRC, haarlem, Undernet. */
sock = socket(AF_INET, SOCK_STREAM, 0);
sin.sin_addr.s_addr = inet_addr("127.0.0.1");
sin.sin_family = AF_INET;
sin.sin_port = htons(80);
connect(sock, (SOCKADDR *)&sin, sizeof(sin));
recv(sock, buffer, sizeof(buffer), 0);
gethostbyname(name); // voila
printf("%s",name); // ou MessageBox(0,name,"nom",0);
closesocket(sock);
WSACleanup();
}
que j'utilise printf ou message box j'obtient toujour : "======================²²²²" ou "ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ`y`y`y"
que faire ?? merci
sachant que le nom reel de mon PC est : "PCTEK"