Anyone know how to get the Version info text that is attached to your exe file?

I need to find out the Version/Sub Version/Legal Text, etc of an .exe

also, when you have a program that includes a Version resource, how can you reference that information from within the project with code. ie. In the file save function, it saves the version build number in the file header. How would you get that information?

thanx
Posted on 2002-01-07 14:13:26 by Rockinronstar
Try GetFileVersionInfo and GetFileVersionInfoSize. Returns a filled in structure with the version info.
Posted on 2002-01-07 14:24:13 by rdaneel
You have to use the GetFileVersionInfo API.
It sends the info to a buffer...
You only have to analyze it after that.

All is there : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/finstlib_9vu7.asp

Regards,

*EDIT* : Damn, it's me that is too late this time. ;)
I had to wait few minutes for the post page to display...
Posted on 2002-01-07 14:30:37 by JCP
thanx, that will work great for extracting from existing files.

Do you know how to get and set this information within your project with code?

In my resource file it has a VS_VERSION_INFO resource that I added with Visual studio for my rources.
How do Get this information using code in my project?
(before an .exe exists)

thanx
Posted on 2002-01-07 14:31:54 by Rockinronstar
I'm afraid you will have to parse your rc file to look for these infos. :(
Posted on 2002-01-07 14:36:07 by JCP
I came across LoadString() - do you think that this can work?
Posted on 2002-01-07 14:45:21 by Rockinronstar
nope, LoadString is out. Will work great for most resources, but not for version info since it doesn't have a numeric identifier attached to it.

you would think there is a way to grab this.

Just wondering. Since this code only executes when the app is running, can I use the GetFileVersion() on itself? I use Win2K, so I am worried about access voilations?

The usual "File in use warning" - wonder if this happens when it tries to access its own executable while running.
Posted on 2002-01-07 14:55:13 by Rockinronstar
LoadString loads a string from the .rc file as a resource that you defined in .rc. Like loading a Bitmap from an .rc except that it's a string. Many people use this string table resource instead of putting hundreds of "Variable db "Blah Blah",0" lines in there main code.

I don't know what end your trying to acheive but maybe masm directives such as TITLE will help. The only other solution besides parsing the .rc I guess would be to modify the PE itself after a successful build. Or maybe I just don't understand what you are trying to do.
Posted on 2002-01-07 14:58:04 by rdaneel
Just really trying to get the version info from the file. Our file save headers will have some these values in them. Its more of an efficiency thing really. We could maintain seperate variables that contain the same values as the Version Info table, but really wanted to tap into it, so that the information is contained in a single place. Don't want to have to modify data in multiple places.

One thing, maybe this will work, how about this.....

Can you use GetFileVersionInfo() on the calling file?

If I can do this then that would work great. I am just worried on systems like Win2K and WinXP that complain about sharing access to files when another program is using it.

Don't know if a call to GetFileVersionInfo() to its own executable would cause any access violation problems?

its definately not the big issue, I can always use the variables that mimic the resource values, but like I mentioned, I always prefer to keep things in one place. Hate having to remember all the places that indicate the same information and change them all.

thanx
Posted on 2002-01-07 16:40:54 by Rockinronstar
Can you use GetFileVersionInfo() on the calling file?

If I can do this then that would work great. I am just worried on systems like Win2K and WinXP that complain about sharing access to files when another program is using it.

Don't know if a call to GetFileVersionInfo() to its own executable would cause any access violation problems?


The best way to know it is to try.
In theory, it should work. I think I have already done it.
If I understand well, you want to get these infos in buffers to, ie, set text on controls (ie. in an "About" dialog), right ?

Cya,
Posted on 2002-01-08 01:00:49 by JCP
File version and the version strings are a bit messy.
You'll need to look into the following APIs:

GetFileVersionInfoSize
GetFileVersionInfo
VerQueryValue
Posted on 2002-01-08 01:43:31 by f0dder
ReadIoSys,

yep, thats pretty much what I need it for. Just want to eliminate having to keep seperate variables in my program that has this information if it already exists in the VS_VERSION table

I'll try the GetFileVersionInfo() later and see if it will access itself

thanx guys
Posted on 2002-01-08 09:21:43 by Rockinronstar