16,470
社区成员
发帖
与我相关
我的任务
分享
CString CTestDlg::GetIPAddress(const CString &sHostName)
{
CString strIP = "";
struct hostent FAR *lpHostEnt = gethostbyname (sHostName);
if (lpHostEnt == NULL) return "";
LPSTR lpAddr = lpHostEnt->h_addr_list[0];
if (lpAddr)
{
struct in_addr inAddr;
memmove (&inAddr, lpAddr, 4);
strIP = inet_ntoa (inAddr);
if (sIPAddress.IsEmpty()) return "";
}
else return "";
return strIP;
}
CString GetIPAddress(const CString &sHostName)