Commit 39788793 for tesseract
commit 397887939a357f166f4674bc1d66bb155795f325
Author: Eduardo Mozart de Oliveira <2974895+eduardomozart@users.noreply.github.com>
Date: Sat Feb 21 06:05:50 2026 -0300
Correct mutex call to prevent multiple instances (#4517)
diff --git a/nsis/tesseract.nsi b/nsis/tesseract.nsi
index 077c23f2..af28a9b5 100644
--- a/nsis/tesseract.nsi
+++ b/nsis/tesseract.nsi
@@ -16,7 +16,6 @@
; https://nsis.sourceforge.io/Docs/Modern%20UI%202/Readme.html
; TODO:
-; * Fix PreventMultipleInstances.
; * Add Tesseract icon and images for installer.
SetCompressor /FINAL /SOLID lzma
@@ -1456,12 +1455,13 @@ FunctionEnd
; Prevent running multiple instances of the installer
Function PreventMultipleInstances
- ; TODO: Does not work.
Push $R0
- System::Call 'kernel32::CreateMutexA(i 0, i 0, t ${PRODUCT_NAME}) ?e'
+ System::Call 'kernel32::CreateMutex(p 0, i 0, t "${PRODUCT_NAME}") p .r1 ?e'
Pop $R0
- StrCmp $R0 0 +3
+ ; 183 is the Windows error code for ERROR_ALREADY_EXISTS
+ StrCmp $R0 183 0 +4
MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running." /SD IDOK
+ Pop $R0
Abort
Pop $R0
FunctionEnd