//获取本机IP地址
char HostName[100];
gethostname(HostName, sizeof(HostName));// 获得本机主机名.
hostent* hn;
hn = gethostbyname(HostName);//根据本机主机名得到本机ip
//CString strIPAddr = inet_ntoa(*(struct in_addr *)hn->h_addr_list[0]);//把ip换成字符串形式
CString strIPAddr(inet_ntoa(*(struct in_addr *)hn->h_addr_list[0]));//把ip换成字符串形式
m_localIP.SetWindowText(strIPAddr);