Solved

VERSION_INFO

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 43
Windows Drag & Drop Location 2 101
Annoying "thing" blocks my view 4 101
how to split multiple lines delimiter : 8 100
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…
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

831 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