Solved

VERSION_INFO

Posted on 2001-09-11
4
338 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
windows 10 how make picture as desktop background 2 58
canBalance challenge 34 70
matchUp  challenge 9 94
Path of Workbook 3 61
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

896 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now