CSocketWrench::GetFirstAlias Method  
 
BOOL GetFirstAlias(
  LPCTSTR lpszHostName,  
  LPTSTR lpszHostAlias,  
  INT nMaxLength  
);
BOOL GetFirstAlias(
  LPCTSTR lpszHostName,  
  CString& strHostAlias  
);

The GetFirstAlias method returns the first alias for the specified host name.

Parameters

lpszHostName
A pointer to a string which specifies the host name that you wish to return aliases for. This should be complete domain name.
lpszHostAlias
A string buffer which will contain the first alias for the specified host name. This string should be at least 64 bytes in length. This argument may also reference a CString object which will contain the host alias when the method returns.
nMaxLength
Maximum number of characters that can be copied into the lpszHostAlias string buffer, including the terminating null byte.

Return Value

If the method succeeds, the return value is non-zero. If the method fails, the return value is zero. To get extended error information, call GetLastError.

Example

CSocketWrench sockClient;
CString strHostAlias;
BOOL bResult;

m_ctlListBox.ResetContent();

bResult = sockClient.GetFirstAlias(m_strHostName, strHostAlias);
if (bResult == FALSE)
{
    sockClient.ShowError();
    return;
}

while (bResult)
{
    m_ctlListBox.AddString(strHostAlias);
    bResult = sockClient.GetNextAlias(strHostAlias);
}

Requirements

Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header: Include cswsock10.h
Import Library: cswskv10.lib
Unicode: Implemented as Unicode and ANSI versions.

See Also

GetHostAddress, GetHostName, GetNextAlias