資源簡介
Windows 平臺下,Qt程序出現(xiàn)錯誤崩潰死機時,可自動監(jiān)測出程序當前的狀態(tài),并重新啟動,同時生成故障日志。適用于例如無人值守的程序。資源包括 1、用于測試的主程序; 2、用于監(jiān)測主程序狀態(tài)的監(jiān)測程序。 如果需要崩潰重啟功能的朋友可以拿去借鑒一下。也可以關(guān)注我的博客,里面有更詳細的演示。

代碼片段和文件信息
#include?“mainwindow.h“
#include?
#include?
/*
?*?當程序出現(xiàn)錯誤時,此函數(shù)被調(diào)用,函數(shù)中可做退出前的某些操作。
*/
LONG?ApplicationCrashHandler(EXCEPTION_POINTERS?*pException)
{
????//?在這里添加處理程序崩潰情況的代碼
????/*some?function()*/
????return?EXCEPTION_EXECUTE_HANDLER;
}
int?main(int?argc?char?*argv[])
{
????//此操作效果為:當程序出現(xiàn)錯誤死機時,不會出現(xiàn)系統(tǒng)的錯誤提示窗口,可直接退出。
????SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)ApplicationCrashHandler);
????QApplication?a(argc?argv);
????MainWindow?w;
????w.show();
????return?a.exec();
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-09-10?13:54??Qt?崩潰重啟\
?????文件??????????88??2019-09-10?13:54??Qt?崩潰重啟\ReadMe.txt
?????目錄???????????0??2019-09-10?13:52??Qt?崩潰重啟\TestView\
?????文件???????20953??2019-09-10?13:48??Qt?崩潰重啟\TestView\Makefile
?????文件???????32902??2019-09-10?13:48??Qt?崩潰重啟\TestView\Makefile.Debug
?????文件???????32971??2019-09-10?13:48??Qt?崩潰重啟\TestView\Makefile.Release
?????文件?????????381??2019-09-10?13:33??Qt?崩潰重啟\TestView\TestView.pro
?????文件???????23670??2019-09-10?13:45??Qt?崩潰重啟\TestView\TestView.pro.user
?????目錄???????????0??2019-09-10?13:52??Qt?崩潰重啟\TestView\debug\
?????文件?????1219727??2019-09-10?13:48??Qt?崩潰重啟\TestView\debug\TestView.exe
?????文件??????448649??2019-09-10?13:48??Qt?崩潰重啟\TestView\debug\main.o
?????文件??????476229??2019-09-10?13:48??Qt?崩潰重啟\TestView\debug\mainwindow.o
?????文件????????3465??2019-09-10?13:48??Qt?崩潰重啟\TestView\debug\moc_mainwindow.cpp
?????文件??????290401??2019-09-10?13:48??Qt?崩潰重啟\TestView\debug\moc_mainwindow.o
?????文件?????????716??2019-09-10?13:48??Qt?崩潰重啟\TestView\main.cpp
?????文件?????????354??2019-09-10?13:36??Qt?崩潰重啟\TestView\mainwindow.cpp
?????文件?????????448??2019-09-10?13:36??Qt?崩潰重啟\TestView\mainwindow.h
?????文件????????1312??2019-09-10?13:36??Qt?崩潰重啟\TestView\mainwindow.ui
?????目錄???????????0??2019-09-10?13:52??Qt?崩潰重啟\TestView\release\
?????文件???????26624??2019-09-10?13:45??Qt?崩潰重啟\TestView\release\TestView.exe
?????文件????????2597??2019-09-10?13:48??Qt?崩潰重啟\TestView\ui_mainwindow.h
?????目錄???????????0??2019-09-10?13:51??Qt?崩潰重啟\watchdog\
?????文件???????20728??2019-06-13?15:19??Qt?崩潰重啟\watchdog\Makefile
?????文件???????36321??2019-06-13?15:19??Qt?崩潰重啟\watchdog\Makefile.Debug
?????文件???????36390??2019-06-13?15:19??Qt?崩潰重啟\watchdog\Makefile.Release
?????目錄???????????0??2019-09-10?13:50??Qt?崩潰重啟\watchdog\debug\
?????文件?????1225171??2019-06-13?15:14??Qt?崩潰重啟\watchdog\debug\watchdog.exe
?????文件????????2823??2019-09-10?13:49??Qt?崩潰重啟\watchdog\log.txt
?????文件?????????801??2019-09-10?11:34??Qt?崩潰重啟\watchdog\main.cpp
?????目錄???????????0??2019-09-10?13:51??Qt?崩潰重啟\watchdog\release\
?????文件????????1842??2019-09-10?13:50??Qt?崩潰重啟\watchdog\release\log.txt
............此處省略11個文件信息
評論
共有 條評論