VersionInfo wrapper usage example

#ifndef _VERSINFO_
   #include "versinfo.hpp"
#endif

#ifndef _STDEXCEPT_
   #include "stdexcept"
#endif

#ifndef _IOSTREAM_
   #include 
#endif

using namespace std;

//-----------------------------------------------------------------------------
int main (int argc, char** argv)
{
try
{
   if (argc !=2)
   {
      cout << "No file name specified" << endl;
      return -1;
   } // endif

   VersionInfo anInfo (argv[1]);
   if (anInfo.hasInfo())
   {
      cout << "File version: "
           << anInfo.majorVersion ()
           << "."
           << anInfo.minorVersion()
           << "."
           << anInfo.build()
           << "."
           << anInfo.subBuild ()
           << endl
           << "Product version: "
           << anInfo.productMajorVersion ()
           << "."
           << anInfo.productMinorVersion()
           << "."
           << anInfo.productBuild()
           << "."
           << anInfo.productSubBuild ()
           << endl;
   }
   else
   {
      cout << "the file has no version info resource" << endl;
   } // endifelse
   return 0;
} // endtry
catch (exception & exc)
{
   cerr << exc.what () << endl;
   return 2;
} // endcatch
} // end main (..)

The code above displays file version and product version information if VERSIONINFO resource is present in the specified .dll or .exe file.

NOTE: the VersionInfo class code has to be linked with version.lib
Back to win32 source code downloads

Copyright © 2000 UAB "BBD SOFT"
All Rights Reserved.
All brand names and products names are trademarks or registered trademarks of their respective companies.