为什么连接不上FTP?
在我下面的程序中,为什么不能实现这个连接,也没什么错误。调试时每次都进入CATHCH块。我在Internet Explorer中用ftp://ftp.microsoft.com可以进入。
盼高手回答,谢谢先。
在.H文件中定义这两个变量
protected:
CFtpConnection* m_pFtpConnection;
CInternetSession* m_pInternetSession;
在.CPP文件中的部分代码如下:
CFTPConnectView::CFTPConnectView()
{
// TODO: add construction code here
m_pInternetSession = new CInternetSession;
}
CFTPConnectView::~CFTPConnectView()
{
if(m_pInternetSession != NULL)
delete m_pInternetSession;
}
/////////////////////////////////////////////////////////////////////////////
// CFTPConnectView message handlers
int CFTPConnectView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
SetTimer(1, 1000, NULL);
return 0;
}
void CFTPConnectView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
KillTimer(nIDEvent);
try
{
m_pFtpConnection = m_pInternetSession->GetFtpConnection("ftp.microsoft.com");
}
catch(CInternetException *pEx)
{
pEx->Delete();
m_pFtpConnection = NULL;
}
CView::OnTimer(nIDEvent);
}