1 // ResizableVersion.cpp: implementation of the CResizableVersion class.
\r
3 /////////////////////////////////////////////////////////////////////////////
\r
5 // This file is part of ResizableLib
\r
6 // http://sourceforge.net/projects/resizablelib
\r
8 // Copyright (C) 2000-2004 by Paolo Messina
\r
9 // http://www.geocities.com/ppescher - mailto:ppescher@hotmail.com
\r
11 // The contents of this file are subject to the Artistic License (the "License").
\r
12 // You may not use this file except in compliance with the License.
\r
13 // You may obtain a copy of the License at:
\r
14 // http://www.opensource.org/licenses/artistic-license.html
\r
16 // If you find this code useful, credits would be nice!
\r
18 /////////////////////////////////////////////////////////////////////////////
\r
21 #include "ResizableVersion.h"
\r
23 //////////////////////////////////////////////////////////////////////
\r
24 // Static initializer object (with macros to hide in ClassView)
\r
26 // static intializer must be called before user code
\r
27 #pragma warning(disable:4073)
\r
28 #pragma init_seg(lib)
\r
31 #define BEGIN_HIDDEN {
\r
32 #define END_HIDDEN }
\r
34 #define BEGIN_HIDDEN
\r
39 struct _VersionInitializer
\r
41 _VersionInitializer()
\r
48 // The one and only version-check object
\r
49 static _VersionInitializer g_version;
\r
51 //////////////////////////////////////////////////////////////////////
\r
52 // Private implementation
\r
54 // DLL Version support
\r
55 #include <shlwapi.h>
\r
57 static DLLVERSIONINFO g_dviCommCtrls;
\r
58 static OSVERSIONINFOEX g_osviWindows;
\r
60 static void CheckOsVersion()
\r
62 // Try calling GetVersionEx using the OSVERSIONINFOEX structure.
\r
63 SecureZeroMemory(&g_osviWindows, sizeof(OSVERSIONINFOEX));
\r
64 g_osviWindows.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
\r
65 if (GetVersionEx((LPOSVERSIONINFO)&g_osviWindows))
\r
68 // If that fails, try using the OSVERSIONINFO structure.
\r
69 g_osviWindows.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
\r
70 if (GetVersionEx((LPOSVERSIONINFO)&g_osviWindows))
\r
73 // When all the above fails, set values for the worst case
\r
74 g_osviWindows.dwMajorVersion = 4;
\r
75 g_osviWindows.dwMinorVersion = 0;
\r
76 g_osviWindows.dwBuildNumber = 0;
\r
77 g_osviWindows.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS;
\r
78 g_osviWindows.szCSDVersion[0] = TEXT('\0');
\r
81 static void CheckCommCtrlsVersion()
\r
83 // Check Common Controls version
\r
84 SecureZeroMemory(&g_dviCommCtrls, sizeof(DLLVERSIONINFO));
\r
85 HMODULE hMod = ::LoadLibrary(_T("comctl32.dll"));
\r
88 // Get the version function
\r
89 DLLGETVERSIONPROC pfnDllGetVersion;
\r
90 pfnDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hMod, "DllGetVersion");
\r
92 if (pfnDllGetVersion != NULL)
\r
94 // Obtain version information
\r
95 g_dviCommCtrls.cbSize = sizeof(DLLVERSIONINFO);
\r
96 if (SUCCEEDED(pfnDllGetVersion(&g_dviCommCtrls)))
\r
98 ::FreeLibrary(hMod);
\r
103 ::FreeLibrary(hMod);
\r
106 // Set values for the worst case
\r
107 g_dviCommCtrls.dwMajorVersion = 4;
\r
108 g_dviCommCtrls.dwMinorVersion = 0;
\r
109 g_dviCommCtrls.dwBuildNumber = 0;
\r
110 g_dviCommCtrls.dwPlatformID = DLLVER_PLATFORM_WINDOWS;
\r
114 //////////////////////////////////////////////////////////////////////
\r
115 // Exported global symbols
\r
117 DWORD realWINVER = 0;
\r
119 #ifdef _WIN32_WINDOWS
\r
120 DWORD real_WIN32_WINDOWS = 0;
\r
123 #ifdef _WIN32_WINNT
\r
124 DWORD real_WIN32_WINNT = 0;
\r
128 DWORD real_WIN32_IE = 0;
\r
131 // macro to convert version numbers to hex format
\r
132 #define CNV_OS_VER(x) ((BYTE)(((BYTE)(x) / 10 * 16) | ((BYTE)(x) % 10)))
\r
134 void InitRealVersions()
\r
136 CheckCommCtrlsVersion();
\r
139 // set real version values
\r
141 realWINVER = MAKEWORD(CNV_OS_VER(g_osviWindows.dwMinorVersion),
\r
142 CNV_OS_VER(g_osviWindows.dwMajorVersion));
\r
144 #ifdef _WIN32_WINDOWS
\r
145 if (g_osviWindows.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
\r
146 real_WIN32_WINDOWS = realWINVER;
\r
148 real_WIN32_WINDOWS = 0;
\r
151 #ifdef _WIN32_WINNT
\r
152 if (g_osviWindows.dwPlatformId == VER_PLATFORM_WIN32_NT)
\r
153 real_WIN32_WINNT = realWINVER;
\r
155 real_WIN32_WINNT = 0;
\r
159 switch (g_dviCommCtrls.dwMajorVersion)
\r
162 switch (g_dviCommCtrls.dwMinorVersion)
\r
165 real_WIN32_IE = 0x0300;
\r
168 real_WIN32_IE = 0x0400;
\r
171 real_WIN32_IE = 0x0401;
\r
174 real_WIN32_IE = 0x0200;
\r
178 if (g_dviCommCtrls.dwMinorVersion > 80)
\r
179 real_WIN32_IE = 0x0501;
\r
181 real_WIN32_IE = 0x0500;
\r
184 real_WIN32_IE = 0x0600; // includes checks for 0x0560 (IE6)
\r