Host-IP auslesen

void GetIP(char* pszIP) 
{ 
    struct hostent* h; 
    WSADATA wsaData; 
    UCHAR ucAddress[4]; 
    CHAR szHostName[MAX_PATH]; 
    int x; 

    WSAStartup(MAKEWORD(1, 1), &wsaData); 
    if (SOCKET_ERROR != gethostname(szHostName, NUM_ELEMENTS(szHostName)))
    {
        if (NULL != (h = gethostbyname(szHostName)))
        {
            for(x = 0; (h->h_addr_list[x]); x++)
            {
                ucAddress[0] = h->h_addr_list[x][0];
                ucAddress[1] = h->h_addr_list[x][1];
                ucAddress[2] = h->h_addr_list[x][2];
                ucAddress[3] = h->h_addr_list[x][3];
                wsprintf(IP_ADRESSE, "%d.%d.%d.%d", ucAddress[0], ucAddress[1], ucAddress[2], ucAddress[3]);
            }
        }
    }

    WSACleanup(); 
}