标签:
void GetPcNameAndIp(CString &strPCName,vector<CString> &vIp) { vIp.clear(); WSADATA wsadata; WORD dwVersionRequested; int err = WSAStartup(dwVersionRequested,&wsadata); char hostname[128]; if(gethostname(hostname,128)==0) { strPCName.Format("%s",hostname); } char buf[20]; struct hostent *pHost = gethostbyname(hostname); CString strTmp; for (int i = 0; pHost != NULL && pHost->h_addr_list[i] != NULL; i++) { strcpy_s(buf,inet_ntoa(*(struct in_addr *)pHost->h_addr_list[i])); strTmp.Format("%s",buf); vIp.push_back(strTmp); } WSACleanup(); }
标签:
原文地址:http://www.cnblogs.com/liuxupiaoshi/p/4239967.html