Archive: Using GetDLLVersion to set $APPVERSION


Using GetDLLVersion to set $APPVERSION
I would like to set the $APPVERSION by getting the version from the main program build version.

I have got the following at the top of my Nsis script file:

; define root variable relative to installer
!define PATH_ROOT "..\..\..\"

GetDLLVersionLocal "${PATH_ROOT}ReleasePNG\ttd.exe" $R0 $R1
IntOp $R2 $R0 / 0x00010000 ; $R2 now contains major version
IntOp $R3 $R0 & 0x0000FFFF ; $R3 now contains minor version
IntOp $R4 $R1 / 0x00010000 ; $R4 now contains release
IntOp $R5 $R1 & 0x0000FFFF ; $R5 now contains build
StrCpy $0 "$R2.$R3.$R4.$R5" ; $0 now contains string like "1.2.0.192"

!define APPVERSION "${0}"
!define APPNAMEANDVERSION "${APPNAME} ${APPVERSION}"


But it gives me the following error:
Error: command GetDLLVersionLocal not valid outside section or function
Error in script "C:\cygwin\home\Luca Spiller\ottd\trunk\os\win32\installer\install.nsi" on line 7 -- aborting creation process
I am getting this because it is not in a section? If so is there a way around this?

Thanks,
Luca Spiller

You can't use run-time commands on compile-time.

If you get the latest development version, you can use the LibraryLocal application which is used by the Library.nsh macros to retrieve a DLL version.

Please see Include\Library.nsh to find out how it works.


Thanks, that looks good - but how can I convert that to a format that will work with $APPVERSION? LibraryLocal gives out $LIBRARY_VERSION_HIGH and $LIBRARY_VERSION_LOW.


You'll have to modify LibraryLocal to do the conversion like you did in your script below.