Solved

VERSION_INFO

Posted on 2001-09-11
4
343 Views
Last Modified: 2013-11-20
Hi, Hope you can help me :-)

Ok, I've just build a new MFC project, by using the Wizard, in Visual Studie. When I look at my resources, I've got somthing caled

Version\ VS_VERSION_INFO

How can I get those data from MainFrame.cpp ?, is there a function like GetVersionStruct() ?

CB.
0
Comment
Question by:win32
[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
  • 2
4 Comments
 
LVL 6

Expert Comment

by:Triskelion
ID: 6475618
0
 
LVL 3

Accepted Solution

by:
GlennDean earned 50 total points
ID: 6477042
Here's some code I wrote to get the file version info.  It assumes there is only one language the product is written for.

char theData[1024];
char versionBuf[4096];
memset(versionBuf,0,4096);
DWORD dwSize = GetFileVersionInfoSize("InterestRateMDI.exe",NULL);
BOOL bSuccess = GetFileVersionInfo("InterestRateMDI.exe",
                                      NULL,
                                      4096,
                                      versionBuf);
if (bSuccess)
{
  void * pKey = NULL;
  unsigned int dwSizeOfValue = 0;

  char itemKey[1024];

  struct LANGANDCODEPAGE {
    WORD wLanguage;
    WORD wCodePage;
  } *lpTranslate;

  unsigned int cbTranslate = 0;    
  // Read the list of languages and code pages.

  VerQueryValue(versionBuf,
          TEXT("\\VarFileInfo\\Translation"),
          (LPVOID*)&lpTranslate,
          &cbTranslate);

  // Read the file description for each language and code page.

  for(int i=0; i < (cbTranslate/sizeof(struct LANGANDCODEPAGE)); i++ )
  {
    wsprintf( itemKey,
     TEXT("\\StringFileInfo\\%04x%04x\\FileVersion"),
     lpTranslate[i].wLanguage,
     lpTranslate[i].wCodePage);

     bSuccess = VerQueryValue(versionBuf,
                itemKey,
               &pKey,
               &dwSizeOfValue);
    memcpy(theData,pKey,dwSizeOfValue);
  }

 }

  Glenn
0
 
LVL 3

Expert Comment

by:GlennDean
ID: 6477065
Some additional comments:
1.  In the line
DWORD dwSize = GetFileVersionInfoSize("InterestRateMDI.exe",NULL);
change "InterestRateMDI.exe" to your executable

2. In the line

   wsprintf( itemKey,
    TEXT("\\StringFileInfo\\%04x%04x\\FileVersion"),
    lpTranslate[i].wLanguage,
    lpTranslate[i].wCodePage);

change FileVersion to one of    
Comments
InternalName
ProductName
CompanyName
LegalCopyright
ProductVersion
FileDescription
LegalTrademarks PrivateBuild
FileVersion
OriginalFilename
SpecialBuild

to get other version information

   Glenn
 
0
 
LVL 2

Expert Comment

by:mirec
ID: 6479964
You can also use:
- Class Wrapper to Retrieve Module Information
(VS_VERSION_INFO Resource) -
by Gene M. Angelo
Yet another class to get all the VS_VERSION_INFO resource
information you need, from any module!

http://www.codeguru.com/misc/GetVersionInfo.html

m.
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

724 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