Solved

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

Posted on 2004-09-24
9
1,767 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using Delphi code in a Builder project that uses a DLL 3 114
How to convert MFC::CString to UTF8 wchar_t* 10 207
Problem with SqlConnection 4 168
Precision Problem in C++ 7 32
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

770 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