class CM_TalkDlg : public CDialog
{
// Construction
public:
CM_TalkDlg(CWnd* pParent = NULL); // standard constructor int GetLocalHostName(const CString& sHostName);
int GetIpAddress(const CString& sHostName,CString& sIpaddress);
}CM_TalkDlg::GetLocalHostName(m_sHostName);
CM_TalkDlg::GetIpAddress(m_sHostName,m_sIpaddress);/********************************************************************/
int CTestWinSockDlg::GetLocalHostName(CString& sHostName)
{
char szHostName[256];
int nRetCode;
nRetCode = gethostname(szHostName,sizeof(szHostName))//调用API来获得主机名;
if(nRetCode != 0)
{
return WSAGetLastError();
}
sHostName = szHostName;
return 0;
}
/********************************************************************/
int CTestWinSockDlg::GetIPAddress(const CString& sHostName,CString& sIPAddress)
{
struct hostent FAR* lpHostEnt = gethostbyname(sHostName);
if(lpHostEnt == NULL)
{
return WSAGetLastError();
}
LPSTR lpAddr = lpHostEnt-> h_addr_list[0];
if(lpAddr)
{
struct in_addr inAddr;
memmove(&inAddr,lpAddr,4);
sIPAddress = inet_ntoa(inAddr);
if(sIPAddress.IsEmpty())
{
return 0;
}
}
return 0;
}
/********************************************************************/
请问这里个m_sHostName,m_sIpaddress该怎么样定义
{
// Construction
public:
CM_TalkDlg(CWnd* pParent = NULL); // standard constructor int GetLocalHostName(const CString& sHostName);
int GetIpAddress(const CString& sHostName,CString& sIpaddress);
}CM_TalkDlg::GetLocalHostName(m_sHostName);
CM_TalkDlg::GetIpAddress(m_sHostName,m_sIpaddress);/********************************************************************/
int CTestWinSockDlg::GetLocalHostName(CString& sHostName)
{
char szHostName[256];
int nRetCode;
nRetCode = gethostname(szHostName,sizeof(szHostName))//调用API来获得主机名;
if(nRetCode != 0)
{
return WSAGetLastError();
}
sHostName = szHostName;
return 0;
}
/********************************************************************/
int CTestWinSockDlg::GetIPAddress(const CString& sHostName,CString& sIPAddress)
{
struct hostent FAR* lpHostEnt = gethostbyname(sHostName);
if(lpHostEnt == NULL)
{
return WSAGetLastError();
}
LPSTR lpAddr = lpHostEnt-> h_addr_list[0];
if(lpAddr)
{
struct in_addr inAddr;
memmove(&inAddr,lpAddr,4);
sIPAddress = inet_ntoa(inAddr);
if(sIPAddress.IsEmpty())
{
return 0;
}
}
return 0;
}
/********************************************************************/
请问这里个m_sHostName,m_sIpaddress该怎么样定义
遇到什么错误?