+#endif // wxUSE_DBGHELP
+
+// Remove warning
+#if wxUSE_DBGHELP
+#define _WXUNUSED(x) x
+#else
+#define _WXUNUSED WXUNUSED
+#endif
+
+bool wxCrashReportImpl::Generate(int _WXUNUSED(flags))
+{
+ if ( m_hFile == INVALID_HANDLE_VALUE )
+ return false;
+
+#if wxUSE_DBGHELP
+ if ( !wxGlobalSEInformation )
+ return false;
+
+ PEXCEPTION_RECORD pExceptionRecord = wxGlobalSEInformation->ExceptionRecord;
+ PCONTEXT pCtx = wxGlobalSEInformation->ContextRecord;
+
+ if ( !pExceptionRecord || !pCtx )
+ return false;
+
+ HANDLE hModuleCrash = OutputBasicContext(pExceptionRecord, pCtx);
+
+ // for everything else we need dbghelp.dll
+ wxDynamicLibrary dllDbgHelp(_T("dbghelp.dll"), wxDL_VERBATIM);
+ if ( dllDbgHelp.IsLoaded() )
+ {
+ if ( ResolveSymFunctions(dllDbgHelp) )
+ {
+ SymSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_UNDNAME);
+
+ // Initialize DbgHelp
+ if ( SymInitialize(GetCurrentProcess(), NULL, TRUE /* invade */) )
+ {
+ OutputStack(pCtx, flags);
+
+ if ( hModuleCrash && (flags & wxCRASH_REPORT_GLOBALS) )
+ {
+ OutputGlobals(hModuleCrash);
+ }
+
+ return true;
+ }
+ }
+ else
+ {
+ Output(_T("Please update your dbghelp.dll version, ")
+ _T("at least version 5.1 is needed!\r\n"));
+ }
+ }
+ else
+ {
+ Output(_T("Please install dbghelp.dll available free of charge ")
+ _T("from Microsoft to get more detailed crash information!"));
+ }
+
+ Output(_T("\r\nLatest dbghelp.dll is available at ")
+ _T("http://www.microsoft.com/whdc/ddk/debugging/\r\n"));
+
+#else // !wxUSE_DBGHELP
+ Output(_T("Support for crash report generation was not included ")
+ _T("in this wxWindows version."));
+#endif // wxUSE_DBGHELP/!wxUSE_DBGHELP
+
+ return true;
+}
+