try
{
file.Open(strPath, CFile::modeRead | CFile::typeBinary);
}
catch (...)
{
int i = GetLastError();
}在这句里,用try去打开文件,结果连异常都没抛出,就直接崩溃了,弄得我也崩溃了
VC6错误提示:
Module:
File:i386\chkesp.c
Line:42The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.可加Q 312211865 传源代码。
请高手救命啊

解决方案 »

  1.   

    try
            {
                file.Open(strPath, CFile::modeRead | CFile::typeBinary);
            }
            catch (...)
            {
                int i = GetLastError();
            }
      

  2.   

    我怀疑你的文件没打开,设个断点调一下,看看你这个strPath是否是空的。
            CStdioFile infile;
    if(!infile.Open(strPath, CFile::modeRead))
    {
    AfxMessageBox("没有找到该文件!");
    return;
    }
      

  3.   

    上传到 download.csdn.net 上吧, 帮你调一下
      

  4.   

    确定是这里出的问题吗?我碰到的这种错一般把工程重新编译一下能解决。出错的原因是调用的com接口类型,和在存根里的不一致。
      

  5.   

    strPath不是空的,查看过,有路径,而且这个文件也确实 存在
      

  6.   

    把| CFile::typeBinary去掉试试
      

  7.   

    这是下载地址http://download.csdn.net/source/2039198
    后来“执着”同志给了个解决办法:把CFile改成了CStdioFile,结果就不崩溃了
    真是奇怪,难道CFile存在bug?
      

  8.   

    这我要是知道,我立马给它KILL掉
      

  9.   

    改用CSdtioFile后,打开时不会崩溃,但是还是抛出了异常,catch里GetLastError(),值是0,查错误代码,结果是“操作成功完成。 ”,真的药崩溃了
      

  10.   

    class FileTransInfo
    {
    char strPathMd5[33];   // 这个地方改一下
    CFile file; //发送的文件对象
    }原来strPathMd5定义为 strPathMd5【32】
    在计算 MD5 的时候 ,strPathMd5 写越界了,覆盖了后面的file对象, 导致 file 在执行open 时异常
      

  11.   

    FileTransInfo::FileTransInfo(BOOL binout, CString strip, UINT sendport, 
    UINT recvport, CString path, DWORD filelen, UINT buffsize, HWND hwnd) :
    bInOut(binout), strIp(strip), nSendPort(sendport), nRecvPort(recvport), 
    strPath(path), nBuffSize(buffsize), nFileLen(filelen), hWnd(hwnd)
    {
    bIsDoing = FALSE;
    bIsComplete = FALSE;
    nDoneLen = 0;
    nUpdateTime = 1000; //默认的更新频率为1000ms
    if(bInOut == TRUE)
    {
    ZeroMemory(strPathMd5, 16);
    }
    else
    {
    CString tmp;
    tmp.Format("%s%s", strIp, strPath);
    UINT8 md5[16];
    GetMd5(tmp.GetBuffer(0), md5);
    for(int i = 0; i < 16; ++i)
    {
    sprintf(&strPathMd5[2 * i], "%02x", md5[i]);
    }
    }
    }
      

  12.   

    看出问题了吗?
    最后一次循环, i = 15
    sprintf(&strPathMd5[30], "%02x", md5[i]);程序的本意是向 strPathMd5[30] strPathMd5[31] 写入2个字符
    但是问题在于,sprintf还会写一个结束符号,也就是 '\0'
    导致 strPathMd5[32]= '\0', 数组越界
    file 对象的内存恰好位于strPathMd5的后面, 导致 file对象内存被破话
    所以 file.open 异常