很标准的代码啊
m_pInetSession = new CInternetSession(AfxGetAppName(), 1, PRE_CONFIG_INTERNET_ACCESS); CFtpConnection* pFTP = NULL;  try
{
pFTP=m_pInetSession->GetFtpConnection(_T("ftp://192.168.20.20"),_T("test"),_T("123456")); }
catch (CInternetException* pEx)
{
// catch errors from WinINet
TCHAR szErr[1024];
if (pEx->GetErrorMessage(szErr, 1024))
AfxMessageBox(szErr, MB_OK);
pEx->Delete();
pFTP = NULL;
}
return pFTP;返回错误是:"无法解析服务器名称和地址".
这是为什么??

解决方案 »

  1.   

    CInternetSession ses;
    CFtpConnection* pFTP=ses.GetFtpConnection("ftp.192.168.20.20","test","123456",21,FALSE);
      

  2.   

    跟踪了一下,下面这样是可以的.
    CInternetSession ses;
    CFtpConnection* pFTP=ses.GetFtpConnection("ftp.dreamtel.com.cn","","",21,FALSE);
      

  3.   

    CInternetSession ses;
    CFtpConnection* pFTP=ses.GetFtpConnection("192.168.20.20","test","123456",21,FALSE);
      

  4.   

    我把ftp://192.168.20.20 这个换成这样192.168.20.20就可以了,这是为什么?
      

  5.   

    m_hConnection = InternetConnect((HINTERNET) *pSession, pstrServer,
    nPort, pstrUserName, pstrPassword, INTERNET_SERVICE_FTP,
    (bPassive ? INTERNET_FLAG_PASSIVE : 0), m_dwContext);ftp://ftp://192.168.20.20所以要写成
    192.168.20.20ftp://192.168.20.20