home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 22 / CD_ASCQ_22_0695.iso / win / fr / yrtrace / ex_btdlg.cpp < prev    next >
C/C++ Source or Header  |  1995-04-23  |  5KB  |  165 lines

  1. /*  Project ex_bcpp
  2.     D. Heiderich
  3.     Copyright ⌐ 1995. All Rights Reserved.
  4.  
  5.     SUBSYSTEM:    ex_bcpp.exe Application
  6.     FILE:         ex_btdlg.cpp
  7.     AUTHOR:       D. Heiderich
  8.  
  9.  
  10.     OVERVIEW
  11.     ========
  12.     Source file for implementation of ex_aboutdlg (TDialog).      
  13. */
  14.  
  15.  
  16. #include <owl\owlpch.h>
  17. #pragma hdrstop
  18.  
  19. #include <owl\static.h>
  20.  
  21. #if !defined(__FLAT__)
  22. #include <ver.h>
  23. #endif
  24.  
  25. #include "x_bcppap.h"
  26. #include "ex_btdlg.h"
  27.  
  28.  
  29. ProjectRCVersion::ProjectRCVersion (TModule *module)
  30. {
  31.     char    appFName[255];
  32.     char    subBlockName[255];
  33.     DWORD   fvHandle;
  34.     UINT    vSize;
  35.  
  36.     FVData = 0;
  37.  
  38.     module->GetModuleFileName(appFName, sizeof(appFName));
  39.     DWORD dwSize = GetFileVersionInfoSize(appFName, &fvHandle);
  40.     if (dwSize) {
  41.         FVData  = (void FAR *)new char[(UINT)dwSize];
  42.         if (GetFileVersionInfo(appFName, fvHandle, dwSize, FVData)) {
  43.             // Copy string to buffer so if the -dc compiler switch (Put constant strings in code segments)
  44.             // is on VerQueryValue will work under Win16.  This works around a problem in Microsoft's ver.dll
  45.             // which writes to the string pointed to by subBlockName.
  46.             lstrcpy(subBlockName, "\\VarFileInfo\\Translation"); 
  47.             if (!VerQueryValue(FVData, subBlockName, (void FAR* FAR*)&TransBlock, &vSize)) {
  48.                 delete FVData;
  49.                 FVData = 0;
  50.             } else
  51.                 // Swap the words so wsprintf will print the lang-charset in the correct format.
  52.                 *(DWORD *)TransBlock = MAKELONG(HIWORD(*(DWORD *)TransBlock), LOWORD(*(DWORD *)TransBlock));
  53.         }
  54.     }
  55. }
  56.  
  57.  
  58. ProjectRCVersion::~ProjectRCVersion ()
  59. {
  60.     if (FVData)
  61.         delete FVData;
  62. }
  63.  
  64.  
  65. BOOL ProjectRCVersion::GetProductName (LPSTR &prodName)
  66. {
  67.     UINT    vSize;
  68.     char    subBlockName[255];
  69.  
  70.     wsprintf(subBlockName, "\\StringFileInfo\\%08lx\\%s", *(DWORD *)TransBlock, (LPSTR)"ProductName");
  71.     return FVData ? VerQueryValue(FVData, subBlockName, (void FAR* FAR*)&prodName, &vSize) : FALSE;
  72. }
  73.  
  74.  
  75. BOOL ProjectRCVersion::GetProductVersion (LPSTR &prodVersion)
  76. {
  77.     UINT    vSize;
  78.     char    subBlockName[255];
  79.  
  80.     wsprintf(subBlockName, "\\StringFileInfo\\%08lx\\%s", *(DWORD *)TransBlock, (LPSTR)"ProductVersion");
  81.     return FVData ? VerQueryValue(FVData, subBlockName, (void FAR* FAR*)&prodVersion, &vSize) : FALSE;
  82. }
  83.  
  84.  
  85. BOOL ProjectRCVersion::GetCopyright (LPSTR ©right)
  86. {
  87.     UINT    vSize;
  88.     char    subBlockName[255];
  89.  
  90.     wsprintf(subBlockName, "\\StringFileInfo\\%08lx\\%s", *(DWORD *)TransBlock, (LPSTR)"LegalCopyright");
  91.     return FVData ? VerQueryValue(FVData, subBlockName, (void FAR* FAR*)©right, &vSize) : FALSE;
  92. }
  93.  
  94.  
  95. BOOL ProjectRCVersion::GetDebug (LPSTR &debug)
  96. {
  97.     UINT    vSize;
  98.     char    subBlockName[255];
  99.  
  100.     wsprintf(subBlockName, "\\StringFileInfo\\%08lx\\%s", *(DWORD *)TransBlock, (LPSTR)"SpecialBuild");
  101.     return FVData ? VerQueryValue(FVData, subBlockName, (void FAR* FAR*)&debug, &vSize) : FALSE;
  102. }
  103.  
  104.  
  105. //{{ex_aboutdlg Implementation}}
  106.  
  107.  
  108. //////////////////////////////////////////////////////////
  109. // ex_aboutdlg
  110. // ==========
  111. // Construction/Destruction handling.
  112. ex_aboutdlg::ex_aboutdlg (TWindow *parent, TResId resId, TModule *module)
  113.     : TDialog(parent, resId, module)
  114. {
  115.     // INSERT>> Your constructor code here.
  116. }
  117.  
  118.  
  119. ex_aboutdlg::~ex_aboutdlg ()
  120. {
  121.     Destroy();
  122.  
  123.     // INSERT>> Your destructor code here.
  124. }
  125.  
  126.  
  127. void ex_aboutdlg::SetupWindow ()
  128. {
  129.     LPSTR prodName = 0, prodVersion = 0, copyright = 0, debug = 0;
  130.  
  131.     // Get the static text for the value based on VERSIONINFO.
  132.     TStatic *versionCtrl = new TStatic(this, IDC_VERSION, 255);
  133.     TStatic *copyrightCtrl = new TStatic(this, IDC_COPYRIGHT, 255);
  134.     TStatic *debugCtrl = new TStatic(this, IDC_DEBUG, 255);
  135.  
  136.     TDialog::SetupWindow();
  137.  
  138.     // Process the VERSIONINFO.
  139.     ProjectRCVersion applVersion(GetModule());
  140.  
  141.     // Get the product name and product version strings.
  142.     if (applVersion.GetProductName(prodName) && applVersion.GetProductVersion(prodVersion)) {
  143.         // IDC_VERSION is the product name and version number, the initial value of IDC_VERSION is
  144.         // the word Version (in whatever language) product name VERSION product version.
  145.         char    buffer[255];
  146.         char    versionName[128];
  147.  
  148.         buffer[0] = '\0';
  149.         versionName[0] = '\0';
  150.  
  151.         versionCtrl->GetText(versionName, sizeof(versionName));
  152.         wsprintf(buffer, "%s %s %s", prodName, versionName, prodVersion);
  153.  
  154.         versionCtrl->SetText(buffer);
  155.     }
  156.  
  157.     //Get the legal copyright string.
  158.     if (applVersion.GetCopyright(copyright))
  159.         copyrightCtrl->SetText(copyright);
  160.  
  161.     // Only get the SpecialBuild text if the VERSIONINFO resource is there.
  162.     if (applVersion.GetDebug(debug))
  163.         debugCtrl->SetText(debug);
  164. }
  165.