How can I use crashRpt in my MFC dialog base project?

183 views
Skip to first unread message

lily

unread,
Dec 29, 2011, 11:59:55 PM12/29/11
to Crashrpt
I am making a dialog base program, and use crashrpt like the
following, but it doesn't work!
int CLinkApp::Run()
{
BOOL bRun;
BOOL bExit=FALSE;
while(!bExit)
{
// I add my crInstall code here
bRun= CWinApp::Run();
bExit=TRUE;

}
return bRun;
}

The crEmulateCrash() does not may an exception, and int j = i / 0;
also can not active crashrpt!

So, if anyone can help me?

zexspectrum

unread,
Dec 31, 2011, 6:57:58 AM12/31/11
to cras...@googlegroups.com
What happens when you call crEmulateCrash()? Does it displays Windows Error Reporting window or just nothing happens?

lily

unread,
Jan 3, 2012, 11:37:06 PM1/3/12
to cras...@googlegroups.com
Yes, It make nothing happen!

zexspectrum

unread,
Jan 4, 2012, 5:47:08 AM1/4/12
to cras...@googlegroups.com
I've prepared a tutorial on how to use CrashRpt with MFC application here  http://www.codeproject.com/KB/MFC/CrashRptTutorial.aspx Can you read it and tell me if this tutorial helped you or not?

lily

unread,
Jan 5, 2012, 7:48:57 PM1/5/12
to cras...@googlegroups.com
Dear zexspectrum:
                   Thank you so much! Your tutorial is very helpful. And I also make a class to encapsulate the CrashRpt Api, the use it as a global variable.


class JohnCrash
{
public: 
    JohnCrash()
    {
        CR_INSTALL_INFO info;
        memset(&info, 0, sizeof(CR_INSTALL_INFO));
        info.cb = sizeof(CR_INSTALL_INFO);
        // software info
        info.uPriorities[CR_HTTP] = 3;
        info.uPriorities[CR_SMTP] = 2;
        info.uPriorities[CR_SMAPI] = 1;
        info.dwFlags = 0;
        info.dwFlags |= CR_INST_SEH_EXCEPTION_HANDLER;
        info.dwFlags |= CR_INST_TERMINATE_HANDLER;
        info.dwFlags |= CR_INST_UNEXPECTED_HANDLER;
        info.dwFlags |= CR_INST_ALL_POSSIBLE_HANDLERS;
        info.dwFlags |= CR_INST_HTTP_BINARY_ENCODING;
        //info.dwFlags |= CR_INST_APP_RESTART;
        info.dwFlags |= CR_INST_DONT_SEND_REPORT;
        //info.dwFlags |= CR_INST_SEND_QUEUED_REPORTS;
        info.pszDebugHelpDLL = NULL;
        info.uMiniDumpType = MiniDumpWithFullMemoryInfo;
        info.pszErrorReportSaveDir = _T("C:\\");

        m_pCrashRpt = new CrAutoInstallHelper(&info);
        if(m_pCrashRpt->m_nInstallStatus!=0)
        {
            TCHAR buff[256];
            crGetLastErrorMsg(buff, 256);
            AfxMessageBox( buff, MB_OK);
        }
    }

    ~JohnCrash()
    {
        if( m_pCrashRpt){ delete m_pCrashRpt;}
    }
private:
    CrAutoInstallHelper* m_pCrashRpt;
};

If there is some bug, please point out for me, thanks!
Reply all
Reply to author
Forward
0 new messages