Ok I know you can do this in Inno Setup:
#define AppVer "0.0.11"
Then use it like
[Setup]
AppVerName={#AppVer}
Now imagine I have a file named VERSION
whose contents are "0.0.11".
Is there a way the contents of the file VERSION
into the Inno Setup preprocessor variable somehow?
Using ISPP's GetFileVersion
function is the preferred method (since your installer version should match your application's version, after all). So if this is what you actually wanted to do, you should accept jachguate's answer.
In case you really do want to read the version from a text file instead of from the executable file, then there are two possibilities:
The first: If you can modify the internal format of the file, then you can simplify things considerably by making it look like an INI file:
[Version]
Ver=0.0.11
Given this, you can use ISPP's ReadIni
function to retrieve the version:
#define AppVer ReadIni("ver.ini", "Version", "Ver", "unknown")
The second alternative, if you can't change the file format, is to use the FileOpen
, FileRead
, and FileClose
ISPP functions, eg:
#define VerFile FileOpen("ver.txt")
#define AppVer FileRead(VerFile)
#expr FileClose(VerFile)
#undef VerFile
I repeat, though: it's better to get the app version from the executable file itself instead. This helps to ensure that everything matches up, for one thing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With