PDA

View Full Version : Get version from a rc file?



fellobo
21st August 2006, 19:46
Does anyone know how to get the version from an rc file? Or is there a better way to keep track of version within QT?

When I used MFC I used 'GetModuleFileName' a win api I passed in an 'AfxGetInstanceHandle' which is an MFC call. I really don't want to keep MFC in my qt program.

Thanks for any help!

e8johan
30th August 2006, 14:18
I'm not sure how you mean. Do you want to get the version of the resource or the version of you application.

If you saved the application's version as a string resource, you can use a const QString or a define just as well.

gfunk
30th August 2006, 19:21
rc files are fairly specific to Windows. ergo, I don't think Qt supports them. Qt has its own resource system to embed resources inside the executable, but is used mostly for storing individual files/graphics, not for plain strings - unless you want to store your string inside a separate file. Otherwise, storing version in a macro #define or const string is fairly typical (and more flexible/portable)

jpn
30th August 2006, 21:52
I tend to use a define in .pro file:



# MMmmPP
# MM = major, mm = minor, PP = patch
DEFINES += MYAPP_VERSION=0x031201




QString version = QString("%1.%2.%3")
.arg((MYAPP_VERSION & 0xFF0000) >> 16, 2, 16, QChar('0'))
.arg((MYAPP_VERSION & 0x00FF00) >> 8, 2, 16, QChar('0'))
.arg((MYAPP_VERSION & 0x0000FF), 2, 16, QChar('0')); // "03.12.01"