Archive: How to recognize NSIS and NSIS Unicode version


How to recognize NSIS and NSIS Unicode version
Hi all.

Is there any safe way how to recognize whether UNICODE version of NSIS is installed?
I want to detect a) NSIS is installed? b) is NSIS UNICODE or not?

Checking "HKLM Software\NSIS\Unicode" or "HKLM Software\NSIS" for installation path sometimes fails - or in some cases user removes the "Unicode" from installation path.

How can I safe recognize these versions?

The very quick and hacky solution is to execute makensis.exe and read first line (saying "MakeNSIS v2.46.5-Unicode - Copyright 1995-2009 Contributors") but maybe there is an easier solution for this.

Thanks!


If, inside your script, you want to check whether it is being compiled by Unicode NSIS or not, you simply use:
!ifdef NSIS_UNICODE

If you want to check whether (Unicode) NSIS is installed on the computer, I think your Registry method is the only good way. Other than that you could check if MakeNSIS.exe exist under the default install path in "%ProgramFiles%\NSIS" or "%ProgramFiles%\NSIS\Unicode", but that's not very reliable, obviously - the user might have installed NSIS to another location.

And if you want to check whether a given MakeNSIS executable is Unicode or not, parsing the console output and checking for "-Unicode", as you suggested, probably is the best way. Alternatively call MakeNSIS.exe with "/HDRINFO" switch and check whether "NSIS_UNICODE" is among the pre-defined symbols. Last but not least, you could call the MakeNSIS.exe and let it compile a script of yours and inside that script you use the "!ifdef" from above to destinguish between "Unicode" and "ANSI" NSIS.


...and the current code in SVN can generate both types. (NSIS_UNICODE is not defined until you use the "Unicode true" attribute)

!if 0x2046000 >= ${NSIS_PACKEDVERSION}
!echo "check NSIS_UNICODE"
!else
Unicode True
!endif

(This version check looks a little weird but provides the best compatibility with !if in older versions of makensis)


The question is really, why do you need to know?

Is it because you need to know what the generated .exe is going to be or is it related to makensis input/output?