1 ////////////////////////////////////////////////////////////////
2 // 1998 Microsoft Systems Journal
4 // If this code works, it was written by Paul DiLascia.
5 // If not, I don't know who wrote it.
14 // tell linker to link with version.lib for VerQueryValue, etc.
15 #pragma comment(linker, "/defaultlib:version.lib")
17 #ifndef DLLVER_PLATFORM_WINDOWS
18 #error ModuleVer.h requires a newer version of the SDK than you have!
19 #error Please update your SDK files.
23 // This class loads a library. Destructor frees for automatic cleanup.
25 class CTRL_EXT_CLASS CLoadLibrary {
29 CLoadLibrary(LPCTSTR lpszName) : m_hinst(LoadLibrary(lpszName)) { }
30 ~CLoadLibrary() { FreeLibrary(m_hinst); }
31 operator HINSTANCE () { return m_hinst; } // cast operator
35 // CModuleVersion version info about a module.
39 // if (ver.GetFileVersionInfo("_T("mymodule))) {
40 // // info is in ver, you can call GetValue to get variable info like
41 // CString s = ver.GetValue(_T("CompanyName"));
44 // You can also call the static fn DllGetVersion to get DLLVERSIONINFO.
46 class CTRL_EXT_CLASS CModuleVersion : public VS_FIXEDFILEINFO {
48 BYTE* m_pVersionInfo; // all version info
51 WORD langID; // language ID
52 WORD charset; // character set (code page)
57 virtual ~CModuleVersion();
59 BOOL GetFileVersionInfo(LPCTSTR modulename);
60 CString GetValue(LPCTSTR lpKeyName);
61 static BOOL DllGetVersion(LPCTSTR modulename, DLLVERSIONINFO& dvi);