je voudrais connaitre mon IP dans un prog en C. pour cela j'ai trouve ce code sur le net :
http://www.geocities.com/omeryesil [...] nameip.htm
Code :
- This code will get the host name and ip for the computer on which the code is run. This works in Visual C++ 5 SP1/2 on NT4 and Windows 9X.
- Requirements
- #include <winsock.h>
- Link with Wsock32.lib
- That's It.
- {
- 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);
- }
- }
- WSACleanup();
- }
- }
|
en fait mon pb se situe a
Code :
- Link with Wsock32.lib
|
je sais pas ou je trouve ca...
j'ai bien des winsock.dll sur mon pc, mais ca marche pas avec
je sais pas trop quoi faire en fait...