[Qt]软件重启
//main.cpp
void SEHExitConfig()
{
SetUnhandledExceptionFilter(CallBackUnhandled);
SetErrorMode(SEM_NOGPFAULTERRORBOX);
set_terminate( TermFunc );
set_unexpected(UnexpectedFunc);
}
int main
{
...
...
int retValue = a.exec();
if(retValue == 1000) //自进程重启
{
SEHExitConfig();
sema.release();
QString exePath = commandParaList[0];
commandParaList.erase(commandParaList.begin());
QProcess::startDetached(exePath, commandParaList);
}
}
程序任意处重启:
qApp()->exit(1000);