lujiguo115 发表于 2015-5-28 13:49:39

一段连接FTP的VC代码

  CInternetSession* m_pInetSession;
CFtpConnection* m_pFtpConnection;



CString strUserName("name");
CString strPassword("XXXX");
CString strServerName(ftp.XXX.com);
CString strObject("/");
  if (m_pFtpConnection != NULL)
m_pFtpConnection->Close();
delete m_pFtpConnection;
m_pFtpConnection = NULL;
  CWaitCursor cursor;
  try
{
m_pFtpConnection = m_pInetSession->GetFtpConnection(strServerName,strUserName,strPassword);
}
catch (CInternetException* pEx)
{
TCHAR szErr;
if (pEx->GetErrorMessage(szErr, 1024))
   AfxMessageBox(szErr, MB_OK);
else
   AfxMessageBox(IDS_EXCEPTION, MB_OK);
pEx->Delete();
  m_pFtpConnection = NULL;
}
  if (m_pFtpConnection != NULL)
{
m_FtpTreeCtl.PopulateTree(m_pFtpConnection, strObject);
}
else
{
m_FtpTreeCtl.PopulateTree();
}
页: [1]
查看完整版本: 一段连接FTP的VC代码