/*
需要添加文件头
#include <Winsock2.h>
#include "afxsock.h"
*/
CString CHTUpdateToolDlg::GetHostAddress()
{
USES_CONVERSION;
AfxSocketInit(NULL);
int error=0;
char HostName[128]={0};
gethostname(HostName,sizeof(HostName));
hostent* hn;
hn=gethostbyname(HostName);//根据本机主机名得到本机ip
CString strIPAddr;
error=GetLastError();
strIPAddr=inet_ntoa(*(struct in_addr*)hn->h_addr_list[0]);
TCHAR strIP[32]={0};
_stprintf(strIP,L"%s",strIPAddr.GetBuffer(1));
strIPAddr.ReleaseBuffer();
return strIP;
}