//获取主机名
BSTR CQyHWinfo::GetMName(void)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CString strResult = L"HE01";
char sHostName[256];
int nRetCode;
nRetCode = gethostname(sHostName,sizeof(sHostName));
if (nRetCode == 0){//获取成功
if (strlen(sHostName) < 100){
WCHAR wcName[100] = {0};
size_t Convert = 0;
mbstowcs_s(&Convert,wcName,100,sHostName,100);
strResult = wcName;
}
}
cout<<"host name:/n"<<sHostName<<endl;
return strResult.AllocSysString();
}
获取主机名
最新推荐文章于 2021-12-06 01:55:09 发布