VS_VERSION_INFO question - Programmer

This is a discussion on VS_VERSION_INFO question - Programmer ; In VS6, the Resource Tab shows a Folder called Version, with information like FILEVERSION and PRODUCTVERSION. How can I retrieve this info in my program? For instance, how do I make the FILEVERSION to show up in a splash screen? ...

+ Reply to Thread
Results 1 to 10 of 10

Thread: VS_VERSION_INFO question

  1. VS_VERSION_INFO question

    In VS6, the Resource Tab shows a Folder called Version, with information
    like FILEVERSION and PRODUCTVERSION. How can I retrieve this info in my
    program? For instance, how do I make the FILEVERSION to show up in a splash
    screen?

    Thanks in advance,
    Harald



  2. Re: VS_VERSION_INFO question

    "Harald Collonia" wrote in message news:...
    > In VS6, the Resource Tab shows a Folder called Version, with information
    > like FILEVERSION and PRODUCTVERSION. How can I retrieve this info in my
    > program? For instance, how do I make the FILEVERSION to show up in a splash
    > screen?


    Check out these 3 functions

    // szFilePath File name to extract version info from.
    "C:\\WINNT\\Explorer.exe"
    // For the current app use
    // GetModuleFileName(AfxGetInstanceHandle(), szFullPath,
    sizeof(szFullPath));
    // szSection Version section data. "ProductVersion"
    // See also -> Version.
    // psData Data read, OR error message.
    //
    // RETURN:
    // True if all went well.

    BOOL GetVersionInfo(LPTSTR szFilePath, LPCTSTR szSection, CString*
    const psData)
    {
    // Inital parameters
    DWORD dwHandle; // Set to Zero (Unused)
    DWORD dwInfoSize; // Size of the Info Structure.
    UINT uiLanguageSize; // Size of language buffer
    UINT uiSize; // Size of Data recieved with version information
    DWORD const* pdwLanguages;

    // Retrieve the File information
    if (dwInfoSize = ::GetFileVersionInfoSize(szFilePath, &dwHandle))
    {
    // Allocate the memory
    BYTE *const pbData = new BYTE[dwInfoSize];
    if (!pbData)
    {
    psData->LoadString(IDS_ERROR_VERSION_INSUF_MEM);
    return FALSE;
    }

    // Get the Version data
    if (::GetFileVersionInfo(szFilePath, dwHandle, dwInfoSize, pbData))
    {
    psData->Empty();
    LPCTSTR szData = NULL; // Pointer to where data will be located

    // Get the translation information. (Language)
    if (::VerQueryValue(pbData, _T("\\VarFileInfo\\Translation"),
    (void**)&pdwLanguages, &uiLanguageSize))
    {
    if (uiLanguageSize)
    {
    TCHAR szSubBlock[512]; // Version language and section
    definition
    _stprintf(szSubBlock, _T("\\StringFileInfo\\%04hX%04hX\\%s"),
    LOWORD(*pdwLanguages), HIWORD(*pdwLanguages), szSection);
    ::VerQueryValue(pbData, szSubBlock, (void**)&szData, &uiSize);
    *psData = szData;

    // This is a happy ending
    delete [] pbData;
    return TRUE;
    }
    }
    }

    psData->LoadString(IDS_ERROR_VERSION_EXTRACT);
    delete [] pbData;
    return FALSE;
    }

    // Failed to locate file or read version data
    psData->LoadString(IDS_ERROR_VERSION_NO_INFO);
    return FALSE;
    }

    BOOL GetVersionInfo(LPTSTR szFilePath, VS_FIXEDFILEINFO* const pInfo)
    {
    // Inital parameters
    DWORD dwHandle; // Set to Zero (Unused)
    DWORD dwInfoSize; // Size of the Info Structure.
    UINT uiSize; // Size of Data recieved with version information
    CString str;

    // Retrieve the File information
    if (dwInfoSize = ::GetFileVersionInfoSize(szFilePath, &dwHandle))
    {
    // Allocate the memory
    BYTE *const pbData = new BYTE[dwInfoSize];
    if (!pbData)
    {
    str.LoadString(IDS_ERROR_VERSION_INSUF_MEM);
    TRACE0(str+"\n");
    return FALSE;
    }

    VS_FIXEDFILEINFO* pData = NULL; // Pointer to where data will be
    located
    // Get the Version data
    if (::GetFileVersionInfo(szFilePath, dwHandle, dwInfoSize, pbData)
    &&
    ::VerQueryValue(pbData, _T("\\"), (void**)&pData, &uiSize))
    {
    // This is a happy ending
    memcpy(pInfo, pData, sizeof(VS_FIXEDFILEINFO));
    delete [] pbData;
    return TRUE;
    }

    str.LoadString(IDS_ERROR_VERSION_EXTRACT);
    TRACE0(str+"\n");
    delete [] pbData;
    return FALSE;
    }

    // Failed to locate file or read version data
    str.LoadString(IDS_ERROR_VERSION_NO_INFO);
    TRACE0(str+"\n");
    return FALSE;
    }

    BOOL GetVersionInfo(LPTSTR szFilePath, DWORD& dwLanguageAndCodepage)
    {
    // Inital parameters
    DWORD dwHandle; // Set to Zero (Unused)
    DWORD dwInfoSize; // Size of the Info Structure.
    UINT uiLanguageSize; // Size of language buffer
    DWORD const* pdwLanguages;
    CString str;

    // Retrieve the File information
    if (dwInfoSize = ::GetFileVersionInfoSize(szFilePath, &dwHandle))
    {
    // Allocate the memory
    BYTE *const pbData = new BYTE[dwInfoSize];
    if (!pbData)
    {
    str.LoadString(IDS_ERROR_VERSION_INSUF_MEM);
    TRACE0(str+"\n");
    return FALSE;
    }

    // Get the Version data
    if (::GetFileVersionInfo(szFilePath, dwHandle, dwInfoSize, pbData))
    {
    // Get the translation information. (Language)
    if (::VerQueryValue(pbData, _T("\\VarFileInfo\\Translation"),
    (void**)&pdwLanguages, &uiLanguageSize))
    {
    if (uiLanguageSize)
    {
    dwLanguageAndCodepage = *pdwLanguages;

    // This is a happy ending
    delete [] pbData;
    return TRUE;
    }
    }
    }

    str.LoadString(IDS_ERROR_VERSION_EXTRACT);
    TRACE0(str+"\n");
    delete [] pbData;
    return FALSE;
    }

    // Failed to locate file or read version data
    str.LoadString(IDS_ERROR_VERSION_NO_INFO);
    TRACE0(str+"\n");
    return FALSE;
    }

    HTH

  3. Re: VS_VERSION_INFO question

    www.baxcode.com/verinfo.htm

    --
    -------------------------------------------------------------------------
    Free software - Baxter Codeworks www.baxcode.com
    -------------------------------------------------------------------------


    "Harald Collonia" wrote in message
    news:aX7Qc.8675$cK.7597@newsread2.news.pas.earthli nk.net...
    > In VS6, the Resource Tab shows a Folder called Version, with information
    > like FILEVERSION and PRODUCTVERSION. How can I retrieve this info in my
    > program? For instance, how do I make the FILEVERSION to show up in a

    splash
    > screen?
    >
    > Thanks in advance,
    > Harald
    >
    >




  4. Re: VS_VERSION_INFO question

    > In VS6, the Resource Tab shows a Folder called Version, with information
    > like FILEVERSION and PRODUCTVERSION. How can I retrieve this info in my
    > program? For instance, how do I make the FILEVERSION to show up in a splash
    > screen?


    Why all the trouble? If this is simply so you can write the version in
    your own apps slash screen, then just create a string and manually
    change it each time you update your application version. Either way
    you will be going to the resource editor to change the FILEVERSION and
    PRODUCTVERSION in the resource editor.


    Simon Hayden
    http://www.AutoUpdatePlus.com
    Get software updates to your clients the Quick and Easy way!
    Latest Version ==========>>> Client Computer

  5. Re: VS_VERSION_INFO question

    You use the VS_VERSION_INFO so that when the user right-clicks on your .exe
    in Explorer and looks at Properties he gets the right information - and you
    don't have two places to update everytime you make a change.

    --
    -------------------------------------------------------------------------
    Free software - Baxter Codeworks www.baxcode.com
    -------------------------------------------------------------------------


    "Simon" wrote in message
    news:8bfaa276.0408162332.7b9dd28a@posting.google.c om...
    > > In VS6, the Resource Tab shows a Folder called Version, with information
    > > like FILEVERSION and PRODUCTVERSION. How can I retrieve this info in my
    > > program? For instance, how do I make the FILEVERSION to show up in a

    splash
    > > screen?

    >
    > Why all the trouble? If this is simply so you can write the version in
    > your own apps slash screen, then just create a string and manually
    > change it each time you update your application version. Either way
    > you will be going to the resource editor to change the FILEVERSION and
    > PRODUCTVERSION in the resource editor.
    >
    >
    > Simon Hayden
    > http://www.AutoUpdatePlus.com
    > Get software updates to your clients the Quick and Easy way!
    > Latest Version ==========>>> Client Computer




  6. Re: VS_VERSION_INFO question

    "Harald Collonia" wrote:

    >In VS6, the Resource Tab shows a Folder called Version, with information
    >like FILEVERSION and PRODUCTVERSION. How can I retrieve this info in my
    >program? For instance, how do I make the FILEVERSION to show up in a splash
    >screen?

    GetFileVersionInfoSize
    GetFileVersionInfo
    VerQueryValue( pBlock, "\\StringFileInfo\\040704b0\\ProductVersion",
    &pszlocVersionString, &lenlocVersionString
    )
    \\StringFileInfo\\040704b0\\ProductVersion is used by me, you should
    encode \StringFileInfo\lang-codepage\string-name.

    For more: RTFM

    Andreas
    --
    A clever person solves a problem.
    A wise person avoids it.
    - Einstein

  7. Re: VS_VERSION_INFO question

    I don't think you want to use this info for your visible version
    number that the user see's. I believe information is used for install
    programs for determining what version of software is already
    installed.


    "Harald Collonia" wrote in message news:...
    > In VS6, the Resource Tab shows a Folder called Version, with information
    > like FILEVERSION and PRODUCTVERSION. How can I retrieve this info in my
    > program? For instance, how do I make the FILEVERSION to show up in a splash
    > screen?
    >
    > Thanks in advance,
    > Harald


  8. Re: VS_VERSION_INFO question

    Not a problem to show versioninfo in the About box. In fact, it gives you
    that "one place" to change things (instead of having to change several
    places).


    --
    -------------------------------------------------------------------------
    Free software - Baxter Codeworks www.baxcode.com
    -------------------------------------------------------------------------


    "Dan" wrote in message
    news:3fb61f1f.0408280634.4d714a28@posting.google.c om...
    > I don't think you want to use this info for your visible version
    > number that the user see's. I believe information is used for install
    > programs for determining what version of software is already
    > installed.
    >
    >
    > "Harald Collonia" wrote in message

    news:...
    > > In VS6, the Resource Tab shows a Folder called Version, with information
    > > like FILEVERSION and PRODUCTVERSION. How can I retrieve this info in my
    > > program? For instance, how do I make the FILEVERSION to show up in a

    splash
    > > screen?
    > >
    > > Thanks in advance,
    > > Harald




  9. Re: VS_VERSION_INFO question

    dany2003@myway.com (Dan) wrote:

    >"Harald Collonia" wrote in message news:...
    >> In VS6, the Resource Tab shows a Folder called Version, with information
    >> like FILEVERSION and PRODUCTVERSION. How can I retrieve this info in my
    >> program? For instance, how do I make the FILEVERSION to show up in a splash
    >> screen?


    >I don't think you want to use this info for your visible version
    >number that the user see's. I believe information is used for install
    >programs for determining what version of software is already
    >installed.


    I use it this way. What's up against this use?
    BTW, my software does not need to be installed, it uses the long
    forgotten way to copy some file to one place, and to start the
    executable. Wonder comes to wonder - none of my customers has had
    problems to manually create a shortcut to the executable and to move
    this shortcut to a location desired, be it the desktop or the
    startmenue.

    Andreas
    --

    A clever person solves a problem.
    A wise person avoids it.
    - Einstein


  10. Re: VS_VERSION_INFO question

    --
    -------------------------------------------------------------------------
    Free software - Baxter Codeworks www.baxcode.com
    -------------------------------------------------------------------------


    "Andreas Hadler" wrote in message
    news:ljf1j09bg93g2ra83bbtk5ioiad42o1uhf@4ax.com...

    > executable. Wonder comes to wonder - none of my customers has had
    > problems to manually create a shortcut to the executable and to move
    > this shortcut to a location desired, be it the desktop or the
    > startmenue.
    >

    Speaking of shortcuts, check out http://www.baxcode.com/shortcut.htm



+ Reply to Thread