Skip to content
⌘ NSIS Forum Archive

langstring ignored in .onInit

7 posts

zarged#

langstring ignored in .onInit

I am using the mutex detect function to see if my installer is running, which works great, but I want to have the correct language used for the messagebox warning. At the moment the LangString is ignored by the .onInit function, is there a way around this?

I am using 2.0b4.
I have attached an example script so you can see what I'm getting at.
Firewall blocked it, added as code:
LangString InstallerRunning ${LANG_ENGLISH} "English: The installer is already running."
LangString InstallerRunning ${LANG_FRENCH} "French: The installer is already running."
LangString InstallerRunning ${LANG_GERMAN} "German: The installer is already running."
LangString InstallerRunning ${LANG_DUTCH} "Dutch: The installer is already running."
LangString InstallerRunning ${LANG_HEBREW} "Hebrew: The installer is already running."

Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "LangString") i .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK $(InstallerRunning)
Abort
FunctionEnd
edited by kichik, script attached below
kichik#
See the following thread:

Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.
kichik#
Originally posted by zarged
Thanks. Any plans to change this behaviour?
Yes, though I'm not sure when exactly. .onGUIInit isn't called when the installer is silent so it's not the best solution.
zarged#
I just use a custom page as the first page which does the checks I want with the correct language in any message boxes. Its not a problem as such but would seem neater, IMHO, if it could be in onInit section instead but this is in no way urgent or anything 😁

Keep up the good work.
Joost Verburg#
You can use .onGuiInit or a Modern UI custom GUIINIT function, that's easier than adding an extra page.

The disadvantage of both methods is that is doesn't work in silent mode.