Board index » cppbuilder » How to get the version information defined in "Project|Option|Version Info" in program?

How to get the version information defined in "Project|Option|Version Info" in program?

Observe:

    {
    char* pszAppName = "mdestiny.exe"; // file
    char pszVerBuff[100]; // receives version
    int iVerBuffLen = 100; // size of buffer
    char pszLangBuff[100]; // receives language
    int iLangBuffLen = 100; // size of buffer
    DWORD dwScratch;
    DWORD* pdwLangChar;
    DWORD dwInfSize ;
    UINT uSize;
    BYTE* pbyInfBuff;
    char szVersion [32];
    char szResource [80];
    char* pszVersion = szVersion;

    dwInfSize = GetFileVersionInfoSize (pszAppName, &dwScratch);

    if (dwInfSize)
        {
        pbyInfBuff = new BYTE [dwInfSize];
        memset (pbyInfBuff, 0, dwInfSize);
        if (pbyInfBuff)
            {
            if (GetFileVersionInfo (pszAppName, 0, dwInfSize,
pbyInfBuff))
                {
                if (VerQueryValue (pbyInfBuff,
"\\VarFileInfo\\Translation", (void**)(&pdwLangChar), &uSize))
                    {
                    if (VerLanguageName (LOWORD (*pdwLangChar),
szResource, sizeof(szResource)))
                        strncpy (pszLangBuff, szResource,
iLangBuffLen);
                    wsprintf (szResource,
"\\StringFileInfo\\%04X%04X\\FileVersion",
                         LOWORD (*pdwLangChar), HIWORD
(*pdwLangChar));

                    if (VerQueryValue (pbyInfBuff, szResource,
(void**)(&pszVersion), &uSize))
                        strncpy (pszVerBuff, pszVersion,
iVerBuffLen-1);
                    }
                }
            Label4->Caption = pszVerBuff;
            Label6->Caption = pszLangBuff;
            delete [] pbyInfBuff;
            }
        }
 }

Hope that helps.

Ron
--
Manifest Destiny -- The Race for World Domination
Demo now available!
http://www.RJ{*word*104}ware.com
news:alt.games.mdestiny

 

Re:How to get the version information defined in "Project|Option|Version Info" in program?


Still the old fashioned way huh? Surely there's an easier way now?

Rob

Quote
Ron Hiler <bnd...@pacbell.net> wrote in message

news:7r4isi$3o68@forums.borland.com...
: Observe:
:
:     {
:     char* pszAppName = "mdestiny.exe"; // file
:     char pszVerBuff[100]; // receives version
:     int iVerBuffLen = 100; // size of buffer
:     char pszLangBuff[100]; // receives language
:     int iLangBuffLen = 100; // size of buffer
:     DWORD dwScratch;
:     DWORD* pdwLangChar;
:     DWORD dwInfSize ;
:     UINT uSize;
:     BYTE* pbyInfBuff;
:     char szVersion [32];
:     char szResource [80];
:     char* pszVersion = szVersion;
:
:     dwInfSize = GetFileVersionInfoSize (pszAppName, &dwScratch);
:
:     if (dwInfSize)
:         {
:         pbyInfBuff = new BYTE [dwInfSize];
:         memset (pbyInfBuff, 0, dwInfSize);
:         if (pbyInfBuff)
:             {
:             if (GetFileVersionInfo (pszAppName, 0, dwInfSize,
: pbyInfBuff))
:                 {
:                 if (VerQueryValue (pbyInfBuff,
: "\\VarFileInfo\\Translation", (void**)(&pdwLangChar), &uSize))
:                     {
:                     if (VerLanguageName (LOWORD (*pdwLangChar),
: szResource, sizeof(szResource)))
:                         strncpy (pszLangBuff, szResource,
: iLangBuffLen);
:                     wsprintf (szResource,
: "\\StringFileInfo\\%04X%04X\\FileVersion",
:                          LOWORD (*pdwLangChar), HIWORD
: (*pdwLangChar));
:
:                     if (VerQueryValue (pbyInfBuff, szResource,
: (void**)(&pszVersion), &uSize))
:                         strncpy (pszVerBuff, pszVersion,
: iVerBuffLen-1);
:                     }
:                 }
:             Label4->Caption = pszVerBuff;
:             Label6->Caption = pszLangBuff;
:             delete [] pbyInfBuff;
:             }
:         }
:  }
:
: Hope that helps.
:
: Ron
: --
: Manifest Destiny -- The Race for World Domination
: Demo now available!
: http://www.RJ{*word*104}ware.com
: news:alt.games.mdestiny
:
:

Re:How to get the version information defined in "Project|Option|Version Info" in program?


Sure, there are plenty of Version components.  I wrote one and so did another
TeamBer whose name escapes me right now.  Goto the Delphi Super page or Torry's
page and you will find many little version components.

Quote
Robert Youdan wrote:

> Still the old fashioned way huh? Surely there's an easier way now?

> Rob

--
Jeff Overcash (TeamB)
      (Please do not email me directly unless  asked. Thank You)
Have you ever met a lady screaming angst potential?
Have you ever dreamed of romance no matter how experimental?
Have you ever felt an alien drifting back into your hometown?
Did you think you were buying safety when you bought that peice of ground?
             (Fish)
--

Re:How to get the version information defined in "Project|Option|Version Info" in program?


Please follow newsgroup guidelines and do not cross or multi post. I answered this
in another forum, and it certainly doesn't belong in the IDE forum.

+===================================================+
| Jonathan Arnold (mailto:jdarn...@buddydog.org)    |
| http://www.buddydog.org                           |
+===================================================+

Q.  What's the difference between ignorance and apathy?
A.  I don't know and I don't care.

Other Threads