ReactOS 0.4.15-dev-7704-gc07eb9f
comctl32supp.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Applications
3 * LICENSE: LGPL - See COPYING in the top level directory
4 * FILE: base/applications/msconfig_new/comctl32ex/comctl32supp.c
5 * PURPOSE: Common Controls helper functions.
6 * COPYRIGHT: Copyright 2011-2012 Hermes BELUSCA - MAITO <hermes.belusca@sfr.fr>
7 */
8
9#include "precomp.h"
10
11HRESULT GetComCtl32Version(OUT PDWORD pdwMajor, OUT PDWORD pdwMinor, OUT PDWORD pdwBuild)
12{
13 HRESULT hr = S_OK;
14 HINSTANCE hDll;
15 DLLGETVERSIONPROC pDllGetVersion;
17
18 *pdwMajor = 0;
19 *pdwMinor = 0;
20 *pdwBuild = 0;
21
22 /*
23 * WARNING! DISCLAIMER!
24 *
25 * This method of retrieving a handle to an already loaded comctl32.dll
26 * is known to not be reliable in case the program is using SxS, or if
27 * this code is used from inside a DLL.
28 */
29
30 /*
31 * See: https://msdn.microsoft.com/en-us/library/windows/desktop/hh298349(v=vs.85).aspx
32 * and: http://www.geoffchappell.com/studies/windows/shell/comctl32/history/
33 * for the possible version values to be returned.
34 */
35
36 /* Get a handle to comctl32.dll that must already be loaded */
37 hDll = GetModuleHandleW(L"comctl32.dll"); // NOTE: We must not call FreeLibrary on the returned handle!
38 if (!hDll) return E_FAIL;
39
40 pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hDll, "DllGetVersion");
41 if (pDllGetVersion)
42 {
43 ZeroMemory(&dvi, sizeof(dvi));
44 dvi.cbSize = sizeof(dvi);
45
46 hr = (*pDllGetVersion)(&dvi);
47 if (SUCCEEDED(hr))
48 {
49 *pdwMajor = dvi.dwMajorVersion;
50 *pdwMinor = dvi.dwMinorVersion;
51 *pdwBuild = dvi.dwBuildNumber;
52
53#if 0
54// #include "stringutils.h"
55
56 LPWSTR strVersion =
57 FormatString(L"ComCtl32 version %d.%d, Build %d, Platform %d",
59 MessageBoxW(NULL, strVersion, L"ComCtl32 version", MB_OK);
60 MemFree(strVersion);
61#endif
62 }
63 }
64 else
65 {
66 /*
67 * If GetProcAddress failed, the DLL is a version
68 * previous to the one shipped with IE 3.x.
69 */
70 *pdwMajor = 4;
71 *pdwMinor = 0;
72 *pdwBuild = 0;
73 }
74
75 return hr;
76}
BOOL MemFree(IN PVOID lpMem)
Definition: utils.c:26
HRESULT GetComCtl32Version(OUT PDWORD pdwMajor, OUT PDWORD pdwMinor, OUT PDWORD pdwBuild)
Definition: comctl32supp.c:11
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
DWORD FormatString(DWORD dwFlags, HINSTANCE hInstance, DWORD dwStringId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, va_list *Arguments)
Definition: fontview.c:34
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define L(x)
Definition: ntvdm.h:50
DWORD * PDWORD
Definition: pedump.c:68
HRESULT hr
Definition: shlfolder.c:183
HRESULT(CALLBACK * DLLGETVERSIONPROC)(DLLVERSIONINFO *)
Definition: shlwapi.h:1964
DWORD dwMajorVersion
Definition: shlwapi.h:1955
DWORD dwBuildNumber
Definition: shlwapi.h:1957
DWORD dwMinorVersion
Definition: shlwapi.h:1956
DWORD dwPlatformID
Definition: shlwapi.h:1958
#define OUT
Definition: typedefs.h:40
#define ZeroMemory
Definition: winbase.h:1712
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_OK
Definition: winuser.h:789
WCHAR * LPWSTR
Definition: xmlstorage.h:184