很标准的代码啊
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;返回错误是:"无法解析服务器名称和地址".
这是为什么??
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;返回错误是:"无法解析服务器名称和地址".
这是为什么??
CFtpConnection* pFTP=ses.GetFtpConnection("ftp.192.168.20.20","test","123456",21,FALSE);
CInternetSession ses;
CFtpConnection* pFTP=ses.GetFtpConnection("ftp.dreamtel.com.cn","","",21,FALSE);
CFtpConnection* pFTP=ses.GetFtpConnection("192.168.20.20","test","123456",21,FALSE);
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