Free Software
Contact me:


CVersionInfo class (verinfo.zip)

Most Windows executables and DLL's have a VS_VERSION_INFO resource associated with them, and this simple C++ class encapsulates the Windows SDK calls which will allow you to programmatically access that information. You can then display the information in a dialog, print it on a report, or use it as part of a functionality test. The class is easily expanded to retrieve the less-frequently used version information.  The class is written in Visual C++ and works well with MFC (but does not require it).

To use, add text or edit boxes to the About dialog in the Resource Editor, and attach appropriate member variables. In the OnInitDialog() of your About box, instantiate an instance of the CVersionInfo class and initialize the member variables as required.

The following MFC source code fragment shows how to get Product Version, Copyright, and Product Name for display in the About box.

#include "VersionInfo.h"
...

BOOL CAboutDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    CVersionInfo verInfo;
    m_sProdVersion = "Version ";
    m_sProdVersion += verInfo.GetProductVersion();
    m_sCopyright = verInfo.GetCopyright();
    m_sProduct = verInfo.GetProductName();
    UpdateData(FALSE);

    return TRUE; // return TRUE unless you set the focus to a control
                 // EXCEPTION: OCX Property Pages should return FALSE
}

This CVersionInfo class is released to the Public Domain and you may use it without need of license or royalty in any of your programs whether for private use or for profit. If you like it, consider linking to my website from yours.

 

Home

© Copyright 2012, Baxter Codeworks