登陆_注册_帮助 2015-06-28 15:58 采纳率: 0%
浏览 2246

MFC多线程,与FTP连接

图片说明

问题貌似出现在 AfxBeginThread(mtQuery, pParam, THREAD_PRIORITY_NORMAL, 0,NULL);
这一行代码中。函数 mtQuery 如下。
为什么会出现上面图片那一行的错误。。

#ifndef MT_H

#define MT_H

#include "stdafx.h"
#include "afxinet.h"

typedef struct PARAM{
CListBox * pListBox;
CString strFtp;
CString strUCount;
CString strUPwd;
}*PPARAM;

UINT _cdecl mtQuery(LPVOID pParam)
{
PPARAM pparam = (PPARAM)pParam;
CListBox * pListBox = pparam->pListBox;

CString strFtp = pparam->strFtp;
CString strUCount = pparam->strUCount;
CString strUPwd = pparam->strUPwd;


CInternetSession * pSession = new CInternetSession(NULL, 1, PRE_CONFIG_INTERNET_ACCESS);
CFtpConnection * pFtpConnection;
try{
    pFtpConnection = pSession->GetFtpConnection(strFtp, strUCount, strUPwd, 21, TRUE);
}
catch (CInternetException* pEx){
    TCHAR error[1024] = { 0 };
    pEx->GetErrorMessage(error, 1024);
    AfxMessageBox(error);
    pEx->Delete();
    pFtpConnection = NULL;
}
if (pFtpConnection != NULL)
{

    CFtpFileFind * pFileFind = new CFtpFileFind(pFtpConnection);

    if (pFileFind != NULL)
    {
        BOOL bContinue = pFileFind->FindFile(L"*");
        if (!bContinue)
        {
            pFileFind->Close();
            pFileFind = NULL;
        }
        while (bContinue)
        {
            bContinue = pFileFind->FindNextFile();
            CString strFileName = pFileFind->GetFileName();
            if (pFileFind->IsDirectory())
            {
                strFileName = L"[" + strFileName + L"]";
            }
            pparam->pListBox->AddString(strFileName);
        }

        if (pFileFind != NULL)
        {
            pFileFind->Close();
            pFileFind = NULL;
        }
        delete pFileFind;
    }
    if (pFtpConnection!=NULL)
    {
        pFtpConnection->Close();
        delete pFtpConnection;
    }

    if (pSession!=NULL)
    {
        pSession->Close();
        delete pSession;
    }
}
return 0;

}

#endif

  • 写回答

2条回答 默认 最新

  • oyljerry 2015-06-28 23:42
    关注

    p Data,pStringManager两个对象是否为合法指针。

    评论

报告相同问题?

悬赏问题

  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler