블로그 이미지
서비
나의 삶을 디자인 한다.

calendar

      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      

Notice

2007/01/19 10:46 Code Library/VC++
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;
}
posted by 서비
TAG
prev 1 ... 10 11 12 13 14 15 next