home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / GETDLL.ZIP / LibraryInfo.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-19  |  23.9 KB  |  1,016 lines

  1. // LibraryInfo.cpp: implementation of the CLibraryInfo class.
  2. //
  3. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  4. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  5. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  6. // PARTICULAR PURPOSE.
  7. //
  8. // Copyright (C) 1995  Kohli Computers, Inc..  All Rights Reserved.
  9. //
  10. //  MODULE: LibrarryInfo.cpp
  11. //
  12. //  PURPOSE: Class used to extract information about a DLL/EXE module. 
  13. //
  14.  
  15.  
  16. #include "stdafx.h"
  17.  
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char THIS_FILE[]=__FILE__;
  21. #define new DEBUG_NEW
  22. #endif
  23.  
  24. //
  25. //    Function:
  26. //        CLibraryInfo()
  27. //
  28. //    Parameters:
  29. //
  30. //    Returns:
  31. //
  32. //    Remarks:
  33. //        Constructor for the class CLibraryInfo
  34. //
  35.     
  36. CLibraryInfo::CLibraryInfo()
  37. {
  38.     m_DllInfo.stDllName = _T("");
  39.     m_DllInfo.stCompany = _T("");
  40.     m_DllInfo.stCopyRight = _T("");
  41.     m_DllInfo.stDescription = _T("");;
  42.     m_DllInfo.stFileVersion = _T("");
  43.     m_DllInfo.stMajorVersion = _T("");
  44.     m_DllInfo.stMinorVersion = _T("");
  45.     m_DllInfo.stInternalName = _T("");
  46.     m_DllInfo.stOriginalName = _T("");
  47.     m_DllInfo.stProductName = _T("");
  48.     m_DllInfo.stProductVersion = _T("");
  49.     m_DllInfo.stDllVersion = _T("");
  50.     m_DllInfo.stFileOS = _T("");
  51.     m_DllInfo.stFileType = _T("");
  52.     m_DllInfo.stLanguageId = _T("");
  53.     m_DllInfo.stCharSet = _T("");
  54.  
  55.     m_pVersionInfo = NULL;
  56.  
  57.     m_bInfoObtained = false;
  58.     m_bLibLoaded = false;
  59. }
  60.  
  61. //
  62. //    Function:
  63. //        ~CLibraryInfo()
  64. //
  65. //    Parameters:
  66. //
  67. //    Returns:
  68. //
  69. //    Remarks:
  70. //        Destructor for the class CLibraryInfo
  71. //
  72.  
  73. CLibraryInfo::~CLibraryInfo()
  74. {
  75.     if (m_pVersionInfo != NULL) {
  76.         delete m_pVersionInfo;
  77.     }
  78. }
  79.  
  80. //
  81. //    Function:
  82. //        SetDllName (const CString & name)
  83. //
  84. //    Parameters:
  85. //        name    Dll/Exe's name
  86. //
  87. //    Returns:
  88. //
  89. //    Remarks:
  90. //        Function sets the name of the Dll/Exe's name in the DLLINFO structure.
  91. //
  92.  
  93. void
  94. CLibraryInfo::SetDllName (const CString & name)
  95. {
  96.     m_bInfoObtained = (name == m_DllInfo.stDllName) ? true : false;
  97.  
  98.     m_DllInfo.stDllName = name;
  99. }
  100.  
  101. //
  102. //    Function:
  103. //        const CString & GetDllName () const
  104. //
  105. //    Parameters:
  106. //
  107. //    Returns:
  108. //        Reference to the Dll/Exe name string.
  109. //
  110. //    Remarks:
  111. //        Function gets the name of the Dll/Exe's name from the DLLINFO structure.
  112. //
  113.  
  114. const CString &
  115. CLibraryInfo::GetDllName () const
  116. {
  117.     return (m_DllInfo.stDllName);
  118. }
  119.  
  120. //
  121. //    Function:
  122. //        bool GetInfo()
  123. //
  124. //    Parameters:
  125. //
  126. //    Returns:
  127. //        true/false - success/error.
  128. //
  129. //    Remarks:
  130. //        Function gets the information for the Dll/Exe module. This function internally
  131. //        calls all the routines for getting static and dynamic information about the module.
  132. //        GetModuleHandle function call succeeds if the module is mapped into the process's
  133. //        memory space. Therefore this function call can't be used for other modules. To
  134. //        make it work for all modules, first call is made to this function, if it fails then
  135. //        the LoadLibrary function call is made to load the module into process's memory
  136. //        space. But care must be taken if the loadlibrary call is used. Make sure to free the
  137. //        module before exiting the module.
  138. //
  139.  
  140. bool CLibraryInfo::GetInfo()
  141. {
  142.     HMODULE hModule;
  143.     DWORD length, size, nullHandle;
  144.     TCHAR fileName [MAX_PATH];
  145.     LPVOID versionPtr;
  146.     UINT verLength;
  147.  
  148.     // Get module handle for dll
  149.     
  150.     if (m_DllInfo.stDllName.IsEmpty ()) {
  151.         return (false);
  152.     }
  153.  
  154.     hModule = ::GetModuleHandle (m_DllInfo.stDllName);
  155.  
  156.     if (hModule == NULL) {
  157.         // the dll/module may not be mapped into our space. So try to load the module
  158.  
  159.         hModule = (HMODULE)LoadLibrary (m_DllInfo.stDllName);
  160.  
  161.         if (hModule == NULL) {
  162.             return (false);
  163.         }
  164.  
  165.         m_bLibLoaded = true;
  166.     }
  167.  
  168.     // Retrieve the full path and filename for the executable file containing
  169.     // the specified module.
  170.  
  171.     size = sizeof (fileName) / sizeof (fileName [0]);
  172.  
  173.     length = ::GetModuleFileName (hModule, fileName, size);
  174.  
  175.     if (length <= 0) {
  176.         if (m_bLibLoaded) {
  177.             FreeLib (hModule);
  178.         }
  179.     }
  180.  
  181.     // Determine whether the operating system can obtain version information
  182.     // about the file. If version information is available, GetFileVersionInfoSize
  183.     // returns the size in bytes of that information. 
  184.     // As with other file installation functions, GetFileVersionInfo works only 
  185.     // with Win32 file images. It does not work with 16-bit Windows file images. 
  186.  
  187.     // Its is neccessary to call this function before calling GetFileVersionInfo.
  188.  
  189.     length = ::GetFileVersionInfoSize (fileName, &nullHandle);
  190.  
  191.     if (length <= 0) {
  192.         if (m_bLibLoaded) {
  193.             FreeLib (hModule);
  194.         }
  195.         return (false);
  196.     }
  197.  
  198.     // Now call the GetFileVersionInfo function to version information
  199.     // First initialize the member variable to recieve the information.
  200.  
  201.     m_pVersionInfo = new BYTE [length];
  202.  
  203.     if (!::GetFileVersionInfo (fileName, NULL, length, m_pVersionInfo)) {
  204.         if (m_bLibLoaded) {
  205.             FreeLib (hModule);
  206.         }
  207.         return (false);
  208.     }
  209.     
  210.     // The Win32 API contains the following predefined version information
  211.     // strings.
  212.     // CompanyName, FileDescription, FileVersion, InternalName, LegalCopyright,
  213.     // OriginalFilename ProductName ProductVersion 
  214.  
  215.     if (!::VerQueryValue (m_pVersionInfo, _T ("\\"), &versionPtr, &verLength)) {
  216.         if (m_bLibLoaded) {
  217.             FreeLib (hModule);
  218.         }
  219.         return (false);
  220.     }
  221.  
  222.     m_FixedFileInfo = *(VS_FIXEDFILEINFO*)versionPtr;
  223.  
  224.     if (!GetDynamicInfo ()) {
  225.         if (m_bLibLoaded) {
  226.             FreeLib (hModule);
  227.         }
  228.         return (false);
  229.     }
  230.  
  231.     // Get the information which is fixed for the module.
  232.  
  233.     if (!GetFixedFileInfo ()) {
  234.         if (m_bLibLoaded) {
  235.             FreeLib (hModule);
  236.         }
  237.         return (false);
  238.     }
  239.  
  240.     // Don't forget to free the loaded library.
  241.  
  242.     if (m_bLibLoaded) {
  243.         FreeLib (hModule);
  244.     }
  245.  
  246.  
  247.     // Set the infoObtained flag to true.
  248.  
  249.     m_bInfoObtained = true;
  250.  
  251.     return (true);
  252. }
  253.  
  254. //
  255. //    Function:
  256. //        bool GetFixedFileInfo()
  257. //
  258. //    Parameters:
  259. //
  260. //    Returns:
  261. //        true/false - success/error
  262. //    
  263. //    Remarks:
  264. //        Function retrieves the information which is ficed for a module e.g. file type, OS etc.
  265. //
  266.  
  267. bool
  268. CLibraryInfo::GetFixedFileInfo()
  269. {
  270.     // dwFileVersionMS specifies the most significant 32 bits of the fileÆs binary
  271.     // version number. This member is used with dwFileVersionLS to form a 64-bit
  272.     // value used for numeric comparisons. 
  273.     // dwFileVersionLS specifies the least significant 32 bits of the fileÆs binary
  274.     // version number. This member is used with dwFileVersionMS to form a 64-bit
  275.     // value used for numeric comparisons
  276.  
  277.     m_DllInfo.stDllVersion.Format ("%d.%d.%d.%d", 
  278.         HIWORD (m_FixedFileInfo.dwFileVersionMS), LOWORD (m_FixedFileInfo.dwFileVersionMS),
  279.         HIWORD (m_FixedFileInfo.dwFileVersionLS), LOWORD (m_FixedFileInfo.dwFileVersionLS));
  280.  
  281.     // Get the file type
  282.  
  283.     if (m_FixedFileInfo.dwFileType == VFT_DRV) {
  284.         switch (m_FixedFileInfo.dwFileSubtype) {
  285.             case VFT2_DRV_DISPLAY:
  286.                 m_DllInfo.stFileType = _T ("Display driver");
  287.                 break;
  288.             case VFT2_DRV_INSTALLABLE:
  289.                 m_DllInfo.stFileType = _T ("Installable driver");
  290.                 break;
  291.             case VFT2_DRV_KEYBOARD:
  292.                 m_DllInfo.stFileType = _T ("Keyboard driver");
  293.                 break;
  294.             case VFT2_DRV_LANGUAGE:
  295.                 m_DllInfo.stFileType = _T ("Language driver");
  296.                 break;
  297.             case VFT2_DRV_MOUSE:
  298.                 m_DllInfo.stFileType = _T ("Mouse driver");
  299.                 break;
  300.             case VFT2_DRV_NETWORK:
  301.                 m_DllInfo.stFileType = _T ("Network driver");
  302.                 break;
  303.             case VFT2_DRV_PRINTER:
  304.                 m_DllInfo.stFileType = _T ("Printer driver");
  305.                 break;
  306.             case VFT2_DRV_SOUND:
  307.                 m_DllInfo.stFileType = _T ("Sound driver");
  308.                 break;
  309.             case VFT2_DRV_SYSTEM:
  310.                 m_DllInfo.stFileType = _T ("System driver");
  311.                 break;
  312.             case VFT2_UNKNOWN:
  313.                 m_DllInfo.stFileType = _T ("Unknown driver");
  314.                 break;
  315.         }
  316.     }
  317.     else if (m_FixedFileInfo.dwFileType == VFT_FONT) {
  318.         switch (m_FixedFileInfo.dwFileSubtype) {
  319.             case VFT2_FONT_RASTER:
  320.                 m_DllInfo.stFileType = _T ("Raster font");
  321.                 break;
  322.             case VFT2_FONT_TRUETYPE:
  323.                 m_DllInfo.stFileType = _T ("Truetype font");
  324.                 break;
  325.             case VFT2_FONT_VECTOR:
  326.                 m_DllInfo.stFileType = _T ("Vector font");
  327.                 break;
  328.             case VFT2_UNKNOWN:
  329.                 m_DllInfo.stFileType = _T ("Unknown font");
  330.                 break;
  331.         }
  332.     }
  333.     else if (m_FixedFileInfo.dwFileType == VFT_APP) {
  334.         m_DllInfo.stFileType = _T ("Application");
  335.     }
  336.     else if (m_FixedFileInfo.dwFileType == VFT_DLL) {
  337.         m_DllInfo.stFileType = _T ("Dynamic link library");
  338.     }
  339.     else if (m_FixedFileInfo.dwFileType == VFT_STATIC_LIB) {
  340.         m_DllInfo.stFileType = _T ("Static link library");
  341.     }
  342.     else if (m_FixedFileInfo.dwFileType == VFT_VXD) {
  343.         m_DllInfo.stFileType = _T ("Virtual device");
  344.     }
  345.     else if (m_FixedFileInfo.dwFileType == VFT_UNKNOWN) {
  346.         m_DllInfo.stFileType = _T ("Unknown type");
  347.     }
  348.  
  349.     // Get OS for which this file was designed
  350.  
  351.     switch (m_FixedFileInfo.dwFileOS) {
  352.         case VOS_DOS:
  353.             m_DllInfo.stFileOS = _T ("MS-DOS");
  354.             break;
  355.         case VOS_DOS_WINDOWS16:
  356.             m_DllInfo.stFileOS = _T ("16-bit windows running on MS-DOS");
  357.             break;
  358.         case VOS_DOS_WINDOWS32:
  359.             m_DllInfo.stFileOS = _T ("Win32 API running on MS-DOS");
  360.             break;
  361.         case VOS_OS216:
  362.             m_DllInfo.stFileOS = _T ("16-bit OS/2");
  363.             break;
  364.         case VOS_OS216_PM16:
  365.             m_DllInfo.stFileOS = _T ("16-bit Presentation manager running on 16-bit OS/2");
  366.             break;
  367.         case VOS_OS232:
  368.             m_DllInfo.stFileOS = _T ("32-bit OS/2");
  369.             break;
  370.         case VOS_NT:
  371.             m_DllInfo.stFileOS = _T ("Windows NT");
  372.             break;
  373.         case VOS_NT_WINDOWS32:
  374.             m_DllInfo.stFileOS = _T ("Win32 API on Windows NT");
  375.             break;
  376.         case VOS_UNKNOWN:
  377.             m_DllInfo.stFileOS = _T ("Unknown OS");
  378.             break;
  379.     }
  380.  
  381.     return (true);
  382.  
  383. }
  384.  
  385. //
  386. //    Function:
  387. //        bool GetDynamicInfo()
  388. //
  389. //    Parameters:
  390. //
  391. //    Returns:
  392. //        true/false - success/error
  393. //
  394. //    Remarks:
  395. //        Function gets the dynamic information of the module e.g. company name, copy right,
  396. //        description, names etc.
  397. //
  398.  
  399. bool
  400. CLibraryInfo::GetDynamicInfo()
  401. {
  402.     UINT verLength;
  403.     LPVOID voidPtr;
  404.     CString query;
  405.  
  406.     // Get the translation information.
  407.     // Translation table consistes of an array of two WORD entries.
  408.     // First entry is langauge Id and second one is character set
  409.  
  410.     // This translation is to be used in subsequent queries for info
  411.  
  412.     if (::VerQueryValue (m_pVersionInfo, "\\VarFileInfo\\Translation", &voidPtr, &verLength)) {
  413.         m_Translation = *(TRANSLATE*)voidPtr;
  414.     }
  415.     
  416.     // GetCompany name
  417.  
  418.     query.Format (_T ("\\StringFileInfo\\%04x%04x\\CompanyName"),
  419.         m_Translation.languageId, m_Translation.characterSet);
  420.  
  421.     ::VerQueryValue (m_pVersionInfo, (LPTSTR)(LPCTSTR)query, (LPVOID*)&m_DllInfo.stCompany,
  422.         &verLength);
  423.  
  424.     
  425.     // Get copy right information.
  426.  
  427.     query.Format (_T ("\\StringFileInfo\\%04x%04x\\LegalCopyRight"),
  428.         m_Translation.languageId, m_Translation.characterSet);
  429.  
  430.     ::VerQueryValue (m_pVersionInfo, (LPTSTR)(LPCTSTR)query, (LPVOID*)&m_DllInfo.stCopyRight,
  431.         &verLength);
  432.  
  433.     // Get product name information
  434.  
  435.     query.Format (_T ("\\StringFileInfo\\%04x%04x\\ProductName"),
  436.         m_Translation.languageId, m_Translation.characterSet);
  437.  
  438.     ::VerQueryValue (m_pVersionInfo, (LPTSTR)(LPCTSTR)query, (LPVOID*)&m_DllInfo.stProductName,
  439.         &verLength);
  440.  
  441.     // Get product version
  442.  
  443.     query.Format (_T ("\\StringFileInfo\\%04x%04x\\ProductVersion"),
  444.         m_Translation.languageId, m_Translation.characterSet);
  445.  
  446.     ::VerQueryValue (m_pVersionInfo, (LPTSTR)(LPCTSTR)query, (LPVOID*)&m_DllInfo.stProductVersion,
  447.         &verLength);
  448.     
  449.     // Get original file name.
  450.  
  451.     query.Format (_T ("\\StringFileInfo\\%04x%04x\\OriginalFileName"),
  452.         m_Translation.languageId, m_Translation.characterSet);
  453.  
  454.     ::VerQueryValue (m_pVersionInfo, (LPTSTR)(LPCTSTR)query, (LPVOID*)&m_DllInfo.stOriginalName,
  455.         &verLength);
  456.  
  457.     // Get original file description.
  458.  
  459.     query.Format (_T ("\\StringFileInfo\\%04x%04x\\FileDescription"),
  460.         m_Translation.languageId, m_Translation.characterSet);
  461.  
  462.     ::VerQueryValue (m_pVersionInfo, (LPTSTR)(LPCTSTR)query, (LPVOID*)&m_DllInfo.stDescription,
  463.         &verLength);
  464.  
  465.     // Get original file version.
  466.  
  467.     query.Format (_T ("\\StringFileInfo\\%04x%04x\\FileVersion"),
  468.         m_Translation.languageId, m_Translation.characterSet);
  469.  
  470.     ::VerQueryValue (m_pVersionInfo, (LPTSTR)(LPCTSTR)query, (LPVOID*)&m_DllInfo.stFileVersion,
  471.         &verLength);
  472.  
  473.     // Get original file version.
  474.  
  475.     query.Format (_T ("\\StringFileInfo\\%04x%04x\\InternalName"),
  476.         m_Translation.languageId, m_Translation.characterSet);
  477.  
  478.     ::VerQueryValue (m_pVersionInfo, (LPTSTR)(LPCTSTR)query, (LPVOID*)&m_DllInfo.stInternalName,
  479.         &verLength);
  480.  
  481.     return (true);
  482. }
  483.  
  484. //
  485. //    Function:
  486. //        void FreeLib (HMODULE hModule)
  487. //
  488. //    Parameters:
  489. //        hModule        Handle to the loaded Dll/Exe module
  490. //
  491. //    Returns:
  492. //
  493. //    Remarks:
  494. //        Function makes Win32 API call to free the module if it was specifically loaded by
  495. //        the application to get module information.
  496. //
  497.  
  498. void
  499. CLibraryInfo::FreeLib (HMODULE hModule)
  500. {
  501.     if (hModule != NULL) {
  502.         FreeLibrary (hModule);
  503.     }
  504. }
  505.  
  506. //
  507. //    bool GetCompanyName(CString & companyName)
  508. //
  509. //    Parameters:
  510. //        companyName        Reference to comapny name string
  511. //
  512. //    Returns:
  513. //        true/false - success/error
  514. //
  515. //    Remarks:
  516. //        Gets the comapny name for the module.
  517. //
  518.  
  519. bool
  520. CLibraryInfo::GetCompanyName(CString & companyName)
  521. {
  522.     bool stat;
  523.  
  524.     // First make sure that we already have all the module information. If not then get the 
  525.     // information first.
  526.  
  527.     stat = (!m_bInfoObtained) ? GetInfo () : true;
  528.  
  529.     companyName = (stat) ? m_DllInfo.stCompany : _T("");
  530.  
  531.     return (stat);
  532. }
  533.  
  534. //
  535. //    bool GetCopyRight(CString & copyRight)
  536. //
  537. //    Parameters:
  538. //        copyRight        Reference to copyright string
  539. //
  540. //    Returns:
  541. //        true/false - success/error
  542. //
  543. //    Remarks:
  544. //        Gets the copyright information for the module.
  545. //
  546.  
  547. bool
  548. CLibraryInfo::GetCopyRight(CString ©Right)
  549. {
  550.     bool stat;
  551.  
  552.     // First make sure that we already have all the module information. If not then get the 
  553.     // information first.
  554.  
  555.     stat = (!m_bInfoObtained) ? GetInfo () : true;
  556.  
  557.     copyRight = (stat) ? m_DllInfo.stCopyRight : _T("");
  558.  
  559.     return (stat);
  560. }
  561.  
  562. //
  563. //    bool GetOrigFileName(CString & origName)
  564. //
  565. //    Parameters:
  566. //        origName        Reference to original module name string
  567. //
  568. //    Returns:
  569. //        true/false - success/error
  570. //
  571. //    Remarks:
  572. //        Gets the original module name for the module.
  573. //
  574.  
  575. bool
  576. CLibraryInfo::GetOrigFileName(CString & origName)
  577. {
  578.     bool stat;
  579.  
  580.     // First make sure that we already have all the module information. If not then get the 
  581.     // information first.
  582.  
  583.     stat = (!m_bInfoObtained) ? GetInfo () : true;
  584.  
  585.     origName = (stat) ? m_DllInfo.stOriginalName : _T("");
  586.  
  587.     return (stat);
  588. }
  589.  
  590. //
  591. //    bool GetInternalName(CString & internalName)
  592. //
  593. //    Parameters:
  594. //        internalName    Reference to intrnal module name string
  595. //
  596. //    Returns:
  597. //        true/false - success/error
  598. //
  599. //    Remarks:
  600. //        Gets the intrnal module name for the module.
  601. //
  602.  
  603. bool
  604. CLibraryInfo::GetInternalName(CString & internalName)
  605. {
  606.     bool stat;
  607.  
  608.     // First make sure that we already have all the module information. If not then get the 
  609.     // information first.
  610.  
  611.     stat = (!m_bInfoObtained) ? GetInfo () : true;
  612.  
  613.     internalName = (stat) ? m_DllInfo.stInternalName : _T("");
  614.  
  615.     return (stat);
  616. }
  617.  
  618. //
  619. //    bool GetProductName(CString & prodName)
  620. //
  621. //    Parameters:
  622. //        prodName    Reference to product name string
  623. //
  624. //    Returns:
  625. //        true/false - success/error
  626. //
  627. //    Remarks:
  628. //        Gets the product name for which the module has been written.
  629. //
  630.  
  631. bool
  632. CLibraryInfo::GetProductName(CString & prodName)
  633. {
  634.     bool stat;
  635.  
  636.     // First make sure that we already have all the module information. If not then get the 
  637.     // information first.
  638.  
  639.     stat = (!m_bInfoObtained) ? GetInfo () : true;
  640.  
  641.     prodName = (stat) ? m_DllInfo.stProductName : _T("");
  642.  
  643.     return (stat);
  644. }
  645.  
  646. //
  647. //    bool GetProductVersion(CString & prodVersion)
  648. //
  649. //    Parameters:
  650. //        prodVersion    Reference to product version string
  651. //
  652. //    Returns:
  653. //        true/false - success/error
  654. //
  655. //    Remarks:
  656. //        Gets the version for the module.
  657. //
  658.  
  659. bool
  660. CLibraryInfo::GetProductVersion(CString & prodVersion)
  661. {
  662.     bool stat;
  663.  
  664.     // First make sure that we already have all the module information. If not then get the 
  665.     // information first.
  666.  
  667.     stat = (!m_bInfoObtained) ? GetInfo () : true;
  668.  
  669.     prodVersion = (stat) ? m_DllInfo.stProductVersion : _T("");
  670.  
  671.     return (stat);
  672. }
  673.  
  674. //
  675. //    bool GetDescription(CString & desc)
  676. //
  677. //    Parameters:
  678. //        desc    Reference to description string
  679. //
  680. //    Returns:
  681. //        true/false - success/error
  682. //
  683. //    Remarks:
  684. //        Gets the description(if available) for the module.
  685. //
  686.  
  687. bool
  688. CLibraryInfo::GetDescription(CString & desc)
  689. {
  690.     bool stat;
  691.  
  692.     // First make sure that we already have all the module information. If not then get the 
  693.     // information first.
  694.  
  695.     stat = (!m_bInfoObtained) ? GetInfo () : true;
  696.  
  697.     desc = (stat) ? m_DllInfo.stDescription : _T("");
  698.  
  699.     return (stat);
  700. }
  701.  
  702. //
  703. //    bool GetFileVersion(CString & fileVer)
  704. //
  705. //    Parameters:
  706. //        fileVer     Reference to file version string
  707. //
  708. //    Returns:
  709. //        true/false - success/error
  710. //
  711. //    Remarks:
  712. //        Gets the file version for the module.
  713. //
  714.  
  715. bool
  716. CLibraryInfo::GetFileVersion(CString & fileVer)
  717. {
  718.     bool stat;
  719.  
  720.     // First make sure that we already have all the module information. If not then get the 
  721.     // information first.
  722.  
  723.     stat = (!m_bInfoObtained) ? GetInfo () : true;
  724.  
  725.     fileVer = (stat) ? m_DllInfo.stFileVersion : _T("");
  726.  
  727.     return (stat);
  728. }
  729.  
  730. //
  731. //    bool GetMajorVersion(CString & majorVer)
  732. //
  733. //    Parameters:
  734. //        majorVer    Reference to file's major version string
  735. //
  736. //    Returns:
  737. //        true/false - success/error
  738. //
  739. //    Remarks:
  740. //        Gets the file's major version numer for the module.
  741. //
  742.  
  743. bool
  744. CLibraryInfo::GetMajorVersion(CString & majorVer)
  745. {
  746.     bool stat;
  747.  
  748.     // First make sure that we already have all the module information. If not then get the 
  749.     // information first.
  750.  
  751.     stat = (!m_bInfoObtained) ? GetInfo () : true;
  752.  
  753.     majorVer = (stat) ? m_DllInfo.stMajorVersion : _T("");
  754.  
  755.     return (stat);
  756. }
  757.  
  758. //
  759. //    bool GetMinorVer(CString & minorVer)
  760. //
  761. //    Parameters:
  762. //        minorVer    Reference to file's minor version string
  763. //
  764. //    Returns:
  765. //        true/false - success/error
  766. //
  767. //    Remarks:
  768. //        Gets the file's minor version numer for the module.
  769. //
  770.  
  771. bool
  772. CLibraryInfo::GetMinorVer(CString & minorVer)
  773. {
  774.     bool stat;
  775.  
  776.     // First make sure that we already have all the module information. If not then get the 
  777.     // information first.
  778.  
  779.     stat = (!m_bInfoObtained) ? GetInfo () : true;
  780.  
  781.     minorVer = (stat) ? m_DllInfo.stMinorVersion : _T("");
  782.  
  783.     return (stat);
  784. }
  785.  
  786. //
  787. //    bool GetLanguage(CString & language)
  788. //
  789. //    Parameters:
  790. //        language    Reference to language string
  791. //
  792. //    Returns:
  793. //        true/false - success/error
  794. //
  795. //    Remarks:
  796. //        Gets the language for which this module has been written.
  797. //
  798.  
  799. bool
  800. CLibraryInfo::GetLanguage(CString & language)
  801. {
  802.     bool stat;
  803.  
  804.     // First make sure that we already have all the module information. If not then get the 
  805.     // information first.
  806.  
  807.     stat = (!m_bInfoObtained) ? GetInfo () : true;
  808.  
  809.     language = (stat) ? m_DllInfo.stLanguageId : _T("");
  810.  
  811.     return (stat);
  812. }
  813.  
  814. //
  815. //    bool GetCharacterSet(CString & characterSet)
  816. //
  817. //    Parameters:
  818. //        characterSet    Reference to language string
  819. //
  820. //    Returns:
  821. //        true/false - success/error
  822. //
  823. //    Remarks:
  824. //        Gets the character set for which this module has been written.
  825. //
  826.  
  827. bool
  828. CLibraryInfo::GetCharacterSet(CString & characterSet)
  829. {
  830.     bool stat;
  831.  
  832.     // First make sure that we already have all the module information. If not then get the 
  833.     // information first.
  834.  
  835.     stat = (!m_bInfoObtained) ? GetInfo () : true;
  836.  
  837.     characterSet = (stat) ? m_DllInfo.stCharSet : _T("");
  838.  
  839.     return (stat);
  840. }
  841.  
  842. //
  843. //    bool GetLanguageId (WORD &langId)
  844. //
  845. //    Parameters:
  846. //        langId    Reference to language id of module.
  847. //
  848. //    Returns:
  849. //        true/false - success/error
  850. //
  851. //    Remarks:
  852. //        Gets the id of the language for which this module has been written. This Id can be
  853. //        derefrenced with the help of Win32 API to get exact language information.
  854. //
  855.  
  856. bool
  857. CLibraryInfo::GetLanguageId (WORD &langId)
  858. {
  859.     bool stat;
  860.  
  861.     // First make sure that we already have all the module information. If not then get the 
  862.     // information first.
  863.  
  864.     stat = (!m_bInfoObtained) ? GetInfo () : true;
  865.  
  866.     langId = (stat) ? m_Translation.languageId : WORD(NULL);
  867.  
  868.     return (stat);
  869. }
  870.  
  871. //
  872. //    bool GetCharacterset (WORD &charSet)
  873. //
  874. //    Parameters:
  875. //        charSet     Reference to character set of module.
  876. //
  877. //    Returns:
  878. //        true/false - success/error
  879. //
  880. //    Remarks:
  881. //        Gets the character set  of the language for which this module has been written. This set can
  882. //        be derefrenced with the help of Win32 API to get exact character set information.
  883. //
  884.  
  885. bool
  886. CLibraryInfo::GetCharacterset (WORD &charSet)
  887. {
  888.     bool stat;
  889.  
  890.     // First make sure that we already have all the module information. If not then get the 
  891.     // information first.
  892.  
  893.     stat = (!m_bInfoObtained) ? GetInfo () : true;
  894.  
  895.     charSet = (stat) ? m_Translation.characterSet : (WORD)NULL;
  896.  
  897.     return (stat);
  898. }
  899.  
  900. //
  901. //    bool GetDllInfo (DLLINFO &info)
  902. //
  903. //    Parameters:
  904. //        info     Reference to DLLINFO structure
  905. //
  906. //    Returns:
  907. //        true/false - success/error
  908. //
  909. //    Remarks:
  910. //        Gets the module information and returns in the DLLINFO structure.
  911. //
  912.  
  913. bool
  914. CLibraryInfo::GetDllInfo (DLLINFO &info)
  915. {
  916.     bool stat;
  917.  
  918.     // First make sure that we already have all the module information. If not then get the 
  919.     // information first.
  920.  
  921.     stat = (!m_bInfoObtained) ? GetInfo () : true;
  922.  
  923.     if (stat) {
  924.         info.stDllName = m_DllInfo.stDllName;
  925.         info.stCompany = m_DllInfo.stCompany;
  926.         info.stCopyRight = m_DllInfo.stCopyRight;
  927.         info.stDescription = m_DllInfo.stDescription;
  928.         info.stFileVersion = m_DllInfo.stFileVersion;
  929.         info.stMajorVersion = m_DllInfo.stMajorVersion;
  930.         info. stMinorVersion = m_DllInfo. stMinorVersion;
  931.         info.stInternalName = m_DllInfo.stInternalName;
  932.         info.stOriginalName = m_DllInfo.stOriginalName;
  933.         info.stProductName  = m_DllInfo.stProductName;
  934.         info.stProductVersion = m_DllInfo.stProductVersion;
  935.         info.stDllVersion = m_DllInfo.stDllVersion;
  936.         info.stFileOS = m_DllInfo.stFileOS;
  937.         info.stFileType = m_DllInfo.stFileType;
  938.         info.stLanguageId = m_DllInfo.stLanguageId;
  939.         info.stCharSet = m_DllInfo.stCharSet;
  940.     }
  941.  
  942.     return (stat);
  943. }
  944.  
  945. //
  946. //    bool GetDllInfo (BYTE *versionInfo)
  947. //
  948. //    Parameters:
  949. //        versionInfo     Pointer to versioninfo
  950. //
  951. //    Returns:
  952. //        true/false - success/error
  953. //
  954. //    Remarks:
  955. //        Gets the pointer to the version info. This pointer can be derefrenced and manipulated to
  956. //        get the complete information about module.
  957. //
  958.  
  959. bool
  960. CLibraryInfo::GetDllInfo (BYTE *versionInfo)
  961. {
  962.     bool stat;
  963.  
  964.     // First make sure that we already have all the module information. If not then get the 
  965.     // information first.
  966.  
  967.     stat = (!m_bInfoObtained) ? GetInfo () : true;
  968.  
  969.     versionInfo = (stat) ? m_pVersionInfo : NULL;
  970.  
  971.     return (stat);
  972. }
  973.  
  974. //
  975. //    bool GetDllInfo (VS_FIXEDFILEINFO &fixedInfo)
  976. //
  977. //    Parameters:
  978. //        fixedInfo     Reference to VS_FIXEDFILEINFO
  979. //
  980. //    Returns:
  981. //        true/false - success/error
  982. //
  983. //    Remarks:
  984. //        Gets the reference to VS_FIXEDFILEINFO data structure which contains complete fixed
  985. //        file info for the module.
  986. //
  987.  
  988. bool
  989. CLibraryInfo::GetDllInfo (VS_FIXEDFILEINFO &fixedInfo)
  990. {
  991.     bool stat;
  992.  
  993.     // First make sure that we already have all the module information. If not then get the 
  994.     // information first.
  995.  
  996.     stat = (!m_bInfoObtained) ? GetInfo () : true;
  997.  
  998.     if (stat) {
  999.         fixedInfo.dwSignature = m_FixedFileInfo.dwSignature;
  1000.         fixedInfo.dwStrucVersion = m_FixedFileInfo.dwStrucVersion;
  1001.         fixedInfo.dwFileVersionMS = m_FixedFileInfo.dwFileVersionMS; 
  1002.         fixedInfo.dwFileVersionLS = m_FixedFileInfo.dwFileVersionLS;
  1003.         fixedInfo.dwProductVersionMS = m_FixedFileInfo.dwProductVersionMS; 
  1004.         fixedInfo.dwProductVersionLS = m_FixedFileInfo.dwProductVersionLS;
  1005.         fixedInfo.dwFileFlagsMask = m_FixedFileInfo.dwFileFlagsMask;
  1006.         fixedInfo.dwFileFlags = m_FixedFileInfo.dwFileFlags; 
  1007.         fixedInfo.dwFileOS = m_FixedFileInfo.dwFileOS;
  1008.         fixedInfo.dwFileType = m_FixedFileInfo.dwFileType;
  1009.         fixedInfo.dwFileSubtype = m_FixedFileInfo.dwFileSubtype; 
  1010.         fixedInfo.dwFileDateMS = m_FixedFileInfo.dwFileDateMS;
  1011.         fixedInfo.dwFileDateLS = m_FixedFileInfo.dwFileDateLS; 
  1012.  
  1013.     }
  1014.  
  1015.     return (stat);
  1016. }