| @@ -15,6 +15,9 @@ | |||||
| #include "osdialog.h" | #include "osdialog.h" | ||||
| #include <unistd.h> | #include <unistd.h> | ||||
| #ifdef ARCH_WIN | |||||
| #include <Windows.h> | |||||
| #endif | |||||
| using namespace rack; | using namespace rack; | ||||
| @@ -44,6 +47,17 @@ int main(int argc, char* argv[]) { | |||||
| patchFile = argv[optind]; | patchFile = argv[optind]; | ||||
| } | } | ||||
| #ifdef ARCH_WIN | |||||
| // Windows global mutex to prevent multiple instances | |||||
| // Handle will be closed by Windows when the process ends | |||||
| HANDLE instanceMutex = CreateMutex(NULL, true, gApplicationName.c_str()); | |||||
| if (GetLastError() == ERROR_ALREADY_EXISTS) { | |||||
| osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, "Rack is already running. Multiple Rack instances are not supported."); | |||||
| exit(1); | |||||
| } | |||||
| (void) instanceMutex; | |||||
| #endif | |||||
| // Initialize environment | // Initialize environment | ||||
| randomInit(); | randomInit(); | ||||
| assetInit(devMode); | assetInit(devMode); | ||||