Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
3.0 KiB

  1. ////////////////////////////////////////////////////////////////
  2. // 1998 Microsoft Systems Journal
  3. //
  4. // If this code works, it was written by Paul DiLascia.
  5. // If not, I don't know who wrote it.
  6. //
  7. // This code appeard in April 1998 edition of Microsoft Systems
  8. // Journal.
  9. //
  10. // 27-July-1998 -- Adapted by James A. McLaughiln (Schlumberger
  11. // Technology Corp.) for Smart Cards. Merged with the concepts from
  12. // CFileVersion class contributed by Manuel Laflamme on a posting to
  13. // www.codeguru.com. If these mods don't work, then you can blame me.
  14. #ifndef SLBMODVER_H
  15. #define SLBMODVER_H
  16. // tell linker to link with version.lib for VerQueryValue, etc.
  17. #pragma comment(linker, "/defaultlib:version.lib")
  18. #ifndef DLLVERSIONINFO
  19. // following is from shlwapi.h, in November 1997 release of the Windows SDK
  20. typedef struct _DllVersionInfo
  21. {
  22. DWORD cbSize;
  23. DWORD dwMajorVersion; // Major version
  24. DWORD dwMinorVersion; // Minor version
  25. DWORD dwBuildNumber; // Build number
  26. DWORD dwPlatformID; // DLLVER_PLATFORM_*
  27. } DLLVERSIONINFO;
  28. // Platform IDs for DLLVERSIONINFO
  29. #define DLLVER_PLATFORM_WINDOWS 0x00000001 // Windows 95
  30. #define DLLVER_PLATFORM_NT 0x00000002 // Windows NT
  31. #endif // DLLVERSIONINFO
  32. //////////////////
  33. // CModuleVersion version info about a module.
  34. // To use:
  35. //
  36. // CModuleVersion ver
  37. // if (ver.GetFileVersionInfo("_T("mymodule))) {
  38. // // info is in ver, you can call GetValue to get variable info like
  39. // CString s = ver.GetValue(_T("CompanyName"));
  40. // }
  41. //
  42. // You can also call the static fn DllGetVersion to get DLLVERSIONINFO.
  43. //
  44. class CModuleVersion : public VS_FIXEDFILEINFO {
  45. protected:
  46. BYTE* m_pVersionInfo; // all version info
  47. struct TRANSLATION {
  48. WORD langID; // language ID
  49. WORD charset; // character set (code page)
  50. } m_translation;
  51. public:
  52. CModuleVersion();
  53. virtual ~CModuleVersion();
  54. BOOL GetFileVersionInfo(LPCTSTR modulename);
  55. BOOL GetFileVersionInfo(HMODULE hModule);
  56. CString GetValue(LPCTSTR lpKeyName);
  57. static BOOL DllGetVersion(LPCTSTR modulename, DLLVERSIONINFO& dvi);
  58. BOOL GetFixedInfo(VS_FIXEDFILEINFO& vsffi);
  59. CString GetFileDescription() {return GetValue(_T("FileDescription")); };
  60. CString GetFileVersion() {return GetValue(_T("FileVersion")); };
  61. CString GetInternalName() {return GetValue(_T("InternalName")); };
  62. CString GetCompanyName() {return GetValue(_T("CompanyName")); };
  63. CString GetLegalCopyright() {return GetValue(_T("LegalCopyright")); };
  64. CString GetOriginalFilename() {return GetValue(_T("OriginalFilename"));};
  65. CString GetProductName() {return GetValue(_T("ProductName")); };
  66. CString GetProductVersion() {return GetValue(_T("ProductVersion")); };
  67. CString GetFixedFileVersion();
  68. CString GetFixedProductVersion();
  69. };
  70. #endif