CString GetIPAddress()
{
WSADATA wsd ;
unsigned long dwBytesRet ;
unsigned int optval = 1 ;
if(WSAStartup(MAKEWORD(2,1),&wsd) != 0)
{
return "";
} //에러
CString ip = "";
char szHostName[256];
PHOSTENT pHostInfo;
if(gethostname(szHostName,sizeof(szHostName)) ==0)
{
if((pHostInfo = gethostbyname(szHostName)) != NULL)
{
ip = inet_ntoa(*(struct in_addr *)*pHostInfo->h_addr_list);
}
}
return ip;
}
TAGTCP/IP
이올린에 북마크하기
이올린에 추천하기