Solved

VERSION_INFO

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 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

18 Experts available now in Live!

Get 1:1 Help Now