Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-09-24
9
Medium Priority
?
1,836 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

610 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