获取本地主机名

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 }

 

posted on 2011-12-23 19:09  Sunny_NUAA  阅读(212)  评论(0编辑  收藏  举报

导航