ReactOS  0.4.12-dev-36-g472787f
comctl32supp.c File Reference
#include "precomp.h"
Include dependency graph for comctl32supp.c:

Go to the source code of this file.

Functions

HRESULT GetComCtl32Version (OUT PDWORD pdwMajor, OUT PDWORD pdwMinor, OUT PDWORD pdwBuild)
 

Function Documentation

◆ GetComCtl32Version()

HRESULT GetComCtl32Version ( OUT PDWORD  pdwMajor,
OUT PDWORD  pdwMinor,
OUT PDWORD  pdwBuild 
)

Definition at line 11 of file comctl32supp.c.

Referenced by TreeView_Set3StateCheck().

12 {
13  HRESULT hr = S_OK;
14  HINSTANCE hDll;
15  DLLGETVERSIONPROC pDllGetVersion;
16  DLLVERSIONINFO dvi;
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 }
DWORD dwMinorVersion
Definition: shlwapi.h:1956
BOOL MemFree(IN PVOID lpMem)
Definition: utils.c:26
#define ZeroMemory
Definition: winbase.h:1635
DWORD FormatString(DWORD dwFlags, HINSTANCE hInstance, DWORD dwStringId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, va_list *Arguments)
Definition: fontview.c:48
#define E_FAIL
Definition: ddrawi.h:102
DWORD dwBuildNumber
Definition: shlwapi.h:1957
DWORD dwMajorVersion
Definition: shlwapi.h:1955
smooth NULL
Definition: ftsmooth.c:416
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
LONG HRESULT
Definition: typedefs.h:77
HRESULT(CALLBACK * DLLGETVERSIONPROC)(DLLVERSIONINFO *)
Definition: shlwapi.h:1964
static const WCHAR L[]
Definition: oid.c:1087
DWORD dwPlatformID
Definition: shlwapi.h:1958
#define S_OK
Definition: intsafe.h:59
#define MB_OK
Definition: winuser.h:784
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:845
#define GetProcAddress(x, y)
Definition: compat.h:410
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define SUCCEEDED(hr)
Definition: intsafe.h:57