Solved

How do I extract the version info from my VS_VERSION_INFO structure ?

Posted on 2004-09-24
9
1,774 Views
Last Modified: 2008-01-09
How do I extract the version info from the VS_VERSION_INFO resource I have in my project ?

My project generates a dll file, so I cannot use the GetFileVersionInfo() to extract the info from the dll file itself, I need to extract the version info from the VS_VERSION_INFO resource I have in my project.
0
Comment
Question by:Morten from Eliten
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 4

Expert Comment

by:DaveyEss
ID: 12140856
0
 

Author Comment

by:Morten from Eliten
ID: 12141503
The link http://www.microsoft.com/msj/0498/c0498.aspx also describes how to extract the version info from a file, not from your current project. Im not able to use this approach, I need to extract the information from the structure which is present in my project, not from the resulting Dll file.
0
 
LVL 4

Expert Comment

by:DaveyEss
ID: 12141636
I'm not sure I follow.  DO you mean you want to get the version info of your project at design time?
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 9

Expert Comment

by:_ys_
ID: 12141730
This article describes a method for embedding version information compile time.
www.dlugosz.com/CPP/Dlugosz_Programming_Guidelines.doc
0
 

Author Comment

by:Morten from Eliten
ID: 12144183
A resource file can contain one or more resources. These can be string resources, bitmaps, icons, version informations, etc.

All these resources have specific API calls that allows you to read that resource. To load a string resource you call LoadString(), to load a bitmap resource you call LoadBitmap(), to load an icon resource you call LoadIcon() - Now what do you call to load a versioninfo ?

The GetFileVersionInfo() and DllGetVersion() require you to load an .exe or .dll file into memory, then query that file for its version info.

First of all, the program I have is already loaded into memory, why would I load it into memory again to query information which already resides somewhere in its memory ?

Secondly since the program resides in a dll file, I have no clue what name this file has (It may have been renamed since it was compiled) and I dont know which folder it resides in (It may have been moved since it was compiled).
0
 
LVL 9

Expert Comment

by:_ys_
ID: 12158241
> the program I have is already loaded into memory, why would I load it into memory again to query information which already resides somewhere in its memory ?
As a DLL can only be loaded once into a process space, the LoadLibrary suite of functions wouldn't load a second instance if it were already there. They simply return a HANDLE to the existing loaded module.

> the program resides in a dll file, I have no clue what name this file has (It may have been renamed since it was compiled) and I dont know which folder it resides in (It may have been moved since it was compiled).
The function GetModuleName can give you the name to pass to GetFileVersionInfo.
0
 

Author Comment

by:Morten from Eliten
ID: 12161282
Well after trying out a large number of items, I finally came up with a way to extract the version numbers directly from the VS_VERSION_INFO resource of my project.

I have pasted the code I used to do so below, if anyone else ever wants to do this:

HRSRC hRes = FindResource(_Module.GetModuleInstance(), MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION);
HGLOBAL hGlobal = LoadResource(_Module.GetModuleInstance(), hRes);
VS_VERSIONINFO *pVersionInfo      = (VS_VERSIONINFO*) LockResource(hGlobal);
char *pInfo = (char*) pVersionInfo;
BYTE sIdentifier[] = {0xBD, 0x04, 0xEF, 0xFE};

for(int nCount=0; nCount<pVersionInfo->wLength-4; nCount++)
{
 if(memcmp(pInfo+nCount, sIdentifier, 4) == 0)
 {
  VS_FIXEDFILEINFO *pFixedFileInfo = (VS_FIXEDFILEINFO*) (pInfo+nCount);
 }
}
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12632997
PAQed with points refunded (50)

modulo
Community Support Moderator
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question