Skip to content

Commit 3978879

Browse files
Correct mutex call to prevent multiple instances (#4517)
1 parent 602fc52 commit 3978879

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

nsis/tesseract.nsi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
; https://nsis.sourceforge.io/Docs/Modern%20UI%202/Readme.html
1717

1818
; TODO:
19-
; * Fix PreventMultipleInstances.
2019
; * Add Tesseract icon and images for installer.
2120

2221
SetCompressor /FINAL /SOLID lzma
@@ -1456,12 +1455,13 @@ FunctionEnd
14561455
14571456
; Prevent running multiple instances of the installer
14581457
Function PreventMultipleInstances
1459-
; TODO: Does not work.
14601458
Push $R0
1461-
System::Call 'kernel32::CreateMutexA(i 0, i 0, t ${PRODUCT_NAME}) ?e'
1459+
System::Call 'kernel32::CreateMutex(p 0, i 0, t "${PRODUCT_NAME}") p .r1 ?e'
14621460
Pop $R0
1463-
StrCmp $R0 0 +3
1461+
; 183 is the Windows error code for ERROR_ALREADY_EXISTS
1462+
StrCmp $R0 183 0 +4
14641463
MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running." /SD IDOK
1464+
Pop $R0
14651465
Abort
14661466
Pop $R0
14671467
FunctionEnd

0 commit comments

Comments
 (0)