18,356
社区成员
发帖
与我相关
我的任务
分享
DWORD dwIP = ntohl(((struct in_addr *)host->h_addr)->s_addr);
char name[128];
struct hostent *pHost;
gethostname(name,128);
pHost = gethostbyname(name);
DWORD dwIP = pHost->h_addr[0] | pHost->h_addr[1] << 8 | pHost->h_addr[2] << 16 | pHost->h_addr[3] << 24;
m_IPAddress_Host.SetAddress(dwIP);
如果发现反了,调整一下下标就行了.