如何知道自己的IP 如题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 补充:命令行中的ipconfig也可以. 能不能说说gethostname怎么用??我手头没有MSDN WSADATA wsaData;WSAStartup(MAKEWORD (2,2), &wsaData);char hostname[40] = {0,};gethostname( hostname, sizeof(hostname));struct hostent *phostent = gethostbyname(hostname);// host namem_strHostName.Format("%s", phostent->h_name ); // host ipchar* stringhostip = inet_ntoa( *(struct in_addr *) phostent->h_addr_list[0] );m_strHostIp.Format("%s", stringhostip);WSACleanup(); 楼上兄弟的代码可以,不过用的时候要包含上头文件#include "Winsock2.h"和Ws2_32.lib gethostname( hostname, sizeof(hostname)); #include "Winsock2.h"#include "Ws2_32.lib"包含了这两个文件会出下面的错误;为什么??急急fatal error C1083: Cannot open include file: 'Ws2_32.lib': No such file or directory 在project->setting中的link里包含,或者add to project->file 晕,我可没有说让你包含"Ws2_32.lib"啊,我的意思是让你连接Ws2_32.lib,我想你看到.lib就应该知道是连接库了啊,晕晕晕晕晕晕晕晕晕晕晕晕晕晕晕晕晕晕晕晕 线程停止问题,请教大家 以下插件引入自己的软件,需要做方面的工作 找个老师...... 关于回调函数如何用的问题 一个内网的机器的ip地址是192.168.0.88 能不能得到它连接到外网的ip地址? MIDI文件格式简介,不知道各位是否有兴趣。 怎样去掉对话框程序在任务栏上的按钮? Inside Visual C++是不是就是VC技术内幕啊 关于构造函数简单问题 如何通过ADO,将sqlserver数据库某一字段下的值赋给Combobox控件 急招MP4人员!(专兼职均可、地区不限) 100分:可不可能实现这样的功能???????
命令行中的ipconfig也可以.
WSAStartup(MAKEWORD (2,2), &wsaData);char hostname[40] = {0,};
gethostname( hostname, sizeof(hostname));
struct hostent *phostent = gethostbyname(hostname);
// host name
m_strHostName.Format("%s", phostent->h_name );
// host ip
char* stringhostip = inet_ntoa( *(struct in_addr *) phostent->h_addr_list[0] );
m_strHostIp.Format("%s", stringhostip);WSACleanup();
#include "Ws2_32.lib"包含了这两个文件会出下面的错误;为什么??急急
fatal error C1083: Cannot open include file: 'Ws2_32.lib': No such file or directory