C...#include <windows.h>... int main(int argc, char *argv[]){ QApplication a(argc, argv); QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QString uniqueNameMutex("--==##UNIQUE-MUTEX##==--"); HANDLE mut = CreateMutex(0, false, uniqueNameMutex.toStdWString().c_str()); DWORD lastError = GetLastError(); if ((mut==0) || (lastError == ERROR_ALREADY_EXISTS)) { QMessageBox msgBox; msgBox.setText(QObject::tr("Program already run.")); msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok); msgBox.show(); return a.exec(); } Widget w; w.hide(); return a.exec();}
C QProcess *process = new QProcess(0); process->start(exePath, QIODevice::ReadOnly); connect(process, SIGNAL(finished(int)), process, SLOT(deleteLater()));