diff --git a/deploy/FortFirewall.iss b/deploy/FortFirewall.iss index 463042be..852d512e 100644 --- a/deploy/FortFirewall.iss +++ b/deploy/FortFirewall.iss @@ -9,6 +9,7 @@ ; NOTE: The value of AppId uniquely identifies this application. ; Do not use the same AppId value in installers for other applications. ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppMutex={#APP_NAME} AppName={#APP_NAME} AppVersion={#APP_VERSION_STR} AppVerName={#APP_NAME} diff --git a/src/ui/fortcommon.cpp b/src/ui/fortcommon.cpp index 1015e5ac..bf638e66 100644 --- a/src/ui/fortcommon.cpp +++ b/src/ui/fortcommon.cpp @@ -1,7 +1,6 @@ #include "fortcommon.h" -#define _WIN32_WINNT 0x0600 - +#define _WIN32_WINNT 0x0600 #define WIN32_LEAN_AND_MEAN #include #include diff --git a/src/ui/main.cpp b/src/ui/main.cpp index 1ab06477..e7bc815c 100644 --- a/src/ui/main.cpp +++ b/src/ui/main.cpp @@ -5,9 +5,12 @@ #include "fortcommon.h" #include "fortmanager.h" #include "fortsettings.h" +#include "util/osutil.h" int main(int argc, char *argv[]) { + OsUtil::createGlobalMutex(APP_NAME); + QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication app(argc, argv); diff --git a/src/ui/util/osutil.cpp b/src/ui/util/osutil.cpp index b05d7b45..b731e040 100644 --- a/src/ui/util/osutil.cpp +++ b/src/ui/util/osutil.cpp @@ -5,6 +5,9 @@ #include #include +#define WIN32_LEAN_AND_MEAN +#include + #include "processinfo.h" OsUtil::OsUtil(QObject *parent) : @@ -33,3 +36,8 @@ QString OsUtil::pidToDosPath(quint32 pid) const ProcessInfo pi(pid); return pi.dosPath(); } + +bool OsUtil::createGlobalMutex(const char *name) +{ + return !CreateMutexA(NULL, FALSE, name); +} diff --git a/src/ui/util/osutil.h b/src/ui/util/osutil.h index 78e28990..2b344cbc 100644 --- a/src/ui/util/osutil.h +++ b/src/ui/util/osutil.h @@ -14,6 +14,8 @@ public: Q_INVOKABLE static void setClipboardData(const QVariant &data); Q_INVOKABLE static QString pidToDosPath(quint32 pid); + + static bool createGlobalMutex(const char *name); }; #endif // OSUTIL_H