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

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两个对象是否为合法指针。

    评论

报告相同问题?

悬赏问题

  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名