Fightin_Foo
7th December 2007 18:11 UTC
Get File Version at Compile
Does anybody know if it is possible to get the version of a file at compile time? Hopefully storing it in a variable or constant. I would like to do my version compare in the .onInit function, so if the user is trying to install an old version on top of a new version it will stop them asap.
Joel
7th December 2007 19:04 UTC
Would be bette during in "runtime"..IfFileExists.
Fightin_Foo
7th December 2007 19:14 UTC
I have no problems getting the version of the file that is actually installed. I am having troubles getting the version of the file that is bundled in the installer. I came up with the idea of setting a variable with the version of the bundled file on compile. That way I can get it set when the installer is built and use it where I need to.
pengyou
7th December 2007 19:36 UTC
Does anybody know if it is possible to get the version of a file at compile time?
GetDLLVersionLocal might do what you want:
http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.3.6Fightin_Foo
7th December 2007 21:54 UTC
Thanks Afrow UK that worked great!
Backland
8th December 2007 13:15 UTC
One suggestion that might save you needing an extra script to get this at runtime:
why dont you extract the new file (at runtime) to the temp directory and get the file versions and compare them?
Afrow UK
8th December 2007 14:10 UTC
Having the version before hand will save you having to extract the files.
Stu
Backland
8th December 2007 14:43 UTC
Considering that the installer already extract quite a few files to the plugins dir, one more file for version checking wouldn't add considerable overhead.
The compile time method doesnt add much either, but I would (personally) do it at runtime and have a simpler script.
ClayDowling
8th December 2007 17:09 UTC
If you're wanting to save yourself the trouble I just included getversion.nsi in the Registration plugin (see the wiki in Plugins). It's written for you and creates a macro you can insert directly into your compiler. An example of how to use it is also included.