Old 23rd November 2012, 15:19   #1
Major Dude
T.Slappy's Avatar
Join Date: Jan 2006
Location: Slovakia
Posts: 540
Send a message via ICQ to T.Slappy
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.


Cool looking installers with custom design: www.graphical-installer.com
Design NSIS setup Pages easily: www.install-designer.com
Build NSIS installers in Visual Studio 2005-2019: www.visual-installer.com
or RAD Studio 2009, 2010, XE-10.3 Rio: www.rad-installer.com
T.Slappy is offline   Reply With Quote
Old 23rd November 2012, 20:52   #2
Major Dude
LoRd_MuldeR's Avatar
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
If, inside your script, you want to check whether it is being compiled by Unicode NSIS or not, you simply use:

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.

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 24th November 2012, 01:41   #3
Anders's Avatar
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,197
...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"
Unicode True

(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?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump