#include "mainwindow.h" #include #include #include #include "base/HGDef.h" #include "base/HGInc.h" #include "base/HGUtility.h" #include "HGVersion.h" #include "curl/curl.h" #if defined(HG_CMP_MSC) #include #endif #if defined(HG_CMP_MSC) static LONG WINAPI UnhandledExceptionFilterEx(struct _EXCEPTION_POINTERS *ExceptionInfo) { HGChar tmpPath[256]; HGBase_GetTmpFileName("dmp", tmpPath, 256); HANDLE hFile = CreateFileA(tmpPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { return EXCEPTION_EXECUTE_HANDLER; } MINIDUMP_EXCEPTION_INFORMATION mdei; mdei.ThreadId = GetCurrentThreadId(); mdei.ExceptionPointers = ExceptionInfo; mdei.ClientPointers = TRUE; MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &mdei, NULL, NULL); CloseHandle(hFile); char exceptionAddr[32] = {0}; #ifdef _WIN64 sprintf(exceptionAddr, "0x%016p", ExceptionInfo->ExceptionRecord->ExceptionAddress); #else sprintf(exceptionAddr, "0x%08p", ExceptionInfo->ExceptionRecord->ExceptionAddress); #endif // 上传 PostCrashInfo(tmpPath, exceptionAddr); HGBase_DeleteFile(tmpPath); return EXCEPTION_EXECUTE_HANDLER; } #endif int main(int argc, char *argv[]) { QApplication a(argc, argv); curl_global_init(CURL_GLOBAL_ALL); #if defined(HG_CMP_MSC) SetUnhandledExceptionFilter(UnhandledExceptionFilterEx); #endif QTranslator translator_qt_; if (translator_qt_.load(":translation/qt_zh_CN.qm")) a.installTranslator(&translator_qt_); QTranslator translator_qt; if (translator_qt.load(":translation/Scanner_zh_CN.qm")) a.installTranslator(&translator_qt); MainWindow w; QScreen *screen = QGuiApplication::primaryScreen(); w.move((screen->size().width() - w.width()) / 2, (screen->size().height() - w.height()) / 2); w.show(); a.exec(); curl_global_cleanup(); return 0; }