View Code
1 int CGetHostNameIPDlg::GetLocalHostName(CString& sHostName)
2 {
3 char szHostName[256];
4 int nRetCode;
5
6 nRetCode = gethostname(szHostName, sizeof(szHostName));
7
8 if (nRetCode != 0) {
9 // An error has occurred
10 sHostName = _T("Not available");;
11 return WSAGetLastError();
12 }
13
14 sHostName = szHostName;
15 return 0;
16 }