獲取計算機的名稱和IP地址
char szHostName[128];
char szT[20];
if( gethostname(szHostName, 128) == 0 )
{
// Get host adresses
m_HostName.SetWindowText(szHostName);
struct hostent * pHost;
int i;
pHost = gethostbyname(szHostName);
for( i = 0; pHost!= NULL && pHost->h_addr_list[i]!= NULL; i++ )
{
char str[100];
char addr[20];
int j;
LPCSTR psz=inet_ntoa (*(struct in_addr *)pHost->h_addr_list[i]);
m_IPAddr.AddString(psz);
}
}