Add links in first start wizard
[TortoiseGit.git] / ext / ResizableLib / ResizableVersion.cpp
blobdd9e74cf3f794a73ed65b5db2037c6691d6b7168
1 // ResizableVersion.cpp: implementation of the CResizableVersion class.
2 //
3 /////////////////////////////////////////////////////////////////////////////
4 //
5 // This file is part of ResizableLib
6 // http://sourceforge.net/projects/resizablelib
7 //
8 // Copyright (C) 2000-2004 by Paolo Messina
9 // http://www.geocities.com/ppescher - mailto:ppescher@hotmail.com
11 // The contents of this file are subject to the Artistic License (the "License").
12 // You may not use this file except in compliance with the License.
13 // You may obtain a copy of the License at:
14 // http://www.opensource.org/licenses/artistic-license.html
16 // If you find this code useful, credits would be nice!
18 /////////////////////////////////////////////////////////////////////////////
20 #include "stdafx.h"
21 #include "ResizableVersion.h"
23 //////////////////////////////////////////////////////////////////////
24 // Static initializer object (with macros to hide in ClassView)
26 // static intializer must be called before user code
27 #pragma warning(disable:4073)
28 #pragma init_seg(lib)
30 #ifdef _UNDEFINED_
31 #define BEGIN_HIDDEN {
32 #define END_HIDDEN }
33 #else
34 #define BEGIN_HIDDEN
35 #define END_HIDDEN
36 #endif
38 BEGIN_HIDDEN
39 struct _VersionInitializer
41 _VersionInitializer()
43 InitRealVersions();
46 END_HIDDEN
48 // The one and only version-check object
49 static _VersionInitializer g_version;
51 //////////////////////////////////////////////////////////////////////
52 // Private implementation
54 // DLL Version support
55 #include <shlwapi.h>
57 static DLLVERSIONINFO g_dviCommCtrls;
59 static void CheckCommCtrlsVersion()
61 // Check Common Controls version
62 SecureZeroMemory(&g_dviCommCtrls, sizeof(DLLVERSIONINFO));
63 HMODULE hMod = AtlLoadSystemLibraryUsingFullPath(_T("comctl32.dll"));
64 if (hMod != NULL)
66 // Get the version function
67 DLLGETVERSIONPROC pfnDllGetVersion;
68 pfnDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hMod, "DllGetVersion");
70 if (pfnDllGetVersion != NULL)
72 // Obtain version information
73 g_dviCommCtrls.cbSize = sizeof(DLLVERSIONINFO);
74 if (SUCCEEDED(pfnDllGetVersion(&g_dviCommCtrls)))
76 ::FreeLibrary(hMod);
77 return;
81 ::FreeLibrary(hMod);
84 // Set values for the worst case
85 g_dviCommCtrls.dwMajorVersion = 4;
86 g_dviCommCtrls.dwMinorVersion = 0;
87 g_dviCommCtrls.dwBuildNumber = 0;
88 g_dviCommCtrls.dwPlatformID = DLLVER_PLATFORM_WINDOWS;
92 //////////////////////////////////////////////////////////////////////
93 // Exported global symbols
95 #ifdef _WIN32_IE
96 DWORD real_WIN32_IE = 0;
97 #endif
99 // macro to convert version numbers to hex format
100 #define CNV_OS_VER(x) ((BYTE)(((BYTE)(x) / 10 * 16) | ((BYTE)(x) % 10)))
102 void InitRealVersions()
104 CheckCommCtrlsVersion();
106 #ifdef _WIN32_IE
107 switch (g_dviCommCtrls.dwMajorVersion)
109 case 4:
110 switch (g_dviCommCtrls.dwMinorVersion)
112 case 70:
113 real_WIN32_IE = 0x0300;
114 break;
115 case 71:
116 real_WIN32_IE = 0x0400;
117 break;
118 case 72:
119 real_WIN32_IE = 0x0401;
120 break;
121 default:
122 real_WIN32_IE = 0x0200;
124 break;
125 case 5:
126 if (g_dviCommCtrls.dwMinorVersion > 80)
127 real_WIN32_IE = 0x0501;
128 else
129 real_WIN32_IE = 0x0500;
130 break;
131 case 6:
132 real_WIN32_IE = 0x0600; // includes checks for 0x0560 (IE6)
133 break;
134 default:
135 real_WIN32_IE = 0;
137 #endif