Hi guys,

Last week me and my friend tried to make a simple project about how to detect our local Address in Visual C++ .

void CAboutDlg::OnDetect()
{
WORD Version;
WSADATA wsaData;
char name[255];
CString ip;
CWaitCursor wait;
PHOSTENT hostinfo;
Version = MAKEWORD( 2, 2 );

if(WSAStartup(Version,&wsaData)==0)
{
if(gethostname ( name, sizeof (name)) ==0)
{
if(hostinfo = gethostbyname (name)) != NULL)
{
ip=inet_ntoa (*(struct in_addr
*)*hostinfo>h_addr_list);
m_cIPAddress.SetWindowText(ip);

m_cName.SetWindowText(name);
m_cIPAddress.EnableWindow(TRUE);
m_cName.EnableWindow(TRUE);
}
}

WSACleanup( );
}

}

when i try to run the programm it doesn't show the Computer name .. it only show the IP Address.
Can anyone help us ?

-Mike