PDA

View Full Version : Accessing version resources from inside the app



bnilsson
26th February 2010, 22:47
Hi!

Both Mac and Windows have application version information, which can be accessed thru "Info" on Mac and "Properties" on Win32, useful stuff especially when you want to make an intelligent installer.

Is it possible to access these version resources from inside the code in a Qt way, e.g. to display the version in the application "About" box?

Or is there some other way to simplify the application version management?


BN

squidge
27th February 2010, 00:10
There are several ways, but I don't think Qt can access Windows resources directly yet (Which the version resource is stored as), so you would have to parse the exe file yourself. An easier alternative (which also gives greater flexibility, but will not show up under Properties) would be to insert your own version information into a unique token in the file (eg. a structure starting with the string "$$VER_INFO$$" for example). For an installer, I'd probably use the later, and just use the former for the human readable part.

bnilsson
27th February 2010, 14:33
Ok.

Is there any native way to access the version resource? I guess there must be.

(Throughout my history of programming, I have always done cross-platform, so I am not good at neither windows or Mac native...)

The most urgent for me would be to get this working in Windows, Mac may wait.

squidge
27th February 2010, 17:49
Sure, under Windows, you can use FindResource, LoadResource, LockResource.

If you want an installer to check the version of a file, try GetFileVersionInfo()

bnilsson
27th February 2010, 19:20
I could not get FindResource etc. to work since I non't understand the terminology involved, not being a Windows man.
So I decided to use GetFileVersionInfo() with the input file parameter from QCoreApplication::applicationFilePath ().
I guess a bit more bulky, but at least I understand it and it works.

BN

bnilsson
27th February 2010, 19:54
Sorry, forgot to say thanks.
The issue is solved and closed,

Regards

BN