标签:data cleanup date tar 计算 地址 获取本机ip 获取 wsad
//IP地址框
// 此段代码:独立的获取本机IP地址和计算机名
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( );
}
m_IPAddress.SetWindowText(ip); // 把IP地址(CString类型)直接显示到IP Address控件中
UpdateData(FALSE);
标签:data cleanup date tar 计算 地址 获取本机ip 获取 wsad
原文地址:http://www.cnblogs.com/thunder-wu/p/6005071.html