BOOL GetLocalHostInfo()
{
//得到主机名称
int nComputerNameLen;
nComputerNameLen = MAX_COMPUTERNAME_LENGTH + 1;
if(SOCKET_ERROR == gethostname(m_chLocalHostName,nComputerNameLen))
return FALSE;
///////end//////////
///得到主机IP地址
HOSTENT *hentThisHost;
hentThisHost=NULL;
if(!(hentThisHost = gethostbyname(m_chLocalHostName)))
return FALSE;
in_addr inaddrThisHost;
memcpy(&inaddrThisHost.S_un.S_addr,hentThisHost->h_addr,hentThisHost->h_length);
strcpy(m_chLocalHostAddr,inet_ntoa(inaddrThisHost));
return TRUE;
}
//获取当前登录账户名
BOOL GetCurrProcessUser(CString& strName)
{
BOOL bRet(TRUE);
strName = _T("");
DWORD dwSize = MAX_PATH;
TCHAR *pszName = new TCHAR[dwSize];
if ( !GetUserName(pszName, &dwSize) )
{
delete[] pszName;
pszName = new TCHAR[dwSize];
bRet = GetUserName( pszName , &dwSize );
}
strName = pszName;
delete[] pszName;
return bRet;
}