?
Solved

VERSION_INFO

Posted on 2001-09-11
4
Medium Priority
?
345 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 200 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

Independent Software Vendors: 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!

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

771 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