Applied backgroundcolors.patch
[TortoiseGit.git] / src / Utils / DllVersion.h
blob991d4e6a4ffe70464c030bdc669d1f35f3dc31f6
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2012 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
21 // functions copied from atlbase.h: those functions got removed
22 // in VS2012...
23 // removed functions: AtlGetShellVersion, AtlGetDllVersion
26 inline HRESULT GetDllVersion(
27 _In_ HINSTANCE hInstDLL,
28 _Out_ DLLVERSIONINFO* pDllVersionInfo)
30 ATLENSURE(pDllVersionInfo);
32 // We must get this function explicitly because some DLLs don't implement it.
33 DLLGETVERSIONPROC pfnDllGetVersion = (DLLGETVERSIONPROC)::GetProcAddress(hInstDLL, "DllGetVersion");
35 if (!pfnDllGetVersion)
36 return E_NOTIMPL;
38 return (*pfnDllGetVersion)(pDllVersionInfo);
41 inline HRESULT GetDllVersion(
42 _In_z_ LPCTSTR lpstrDllName,
43 _Out_ DLLVERSIONINFO* pDllVersionInfo)
45 HINSTANCE hInstDLL = ::LoadLibrary(lpstrDllName);
46 if (!hInstDLL)
47 return AtlHresultFromLastError();
48 HRESULT hRet = GetDllVersion(hInstDLL, pDllVersionInfo);
49 ::FreeLibrary(hInstDLL);
50 return hRet;
53 // Shell Versions:
54 // WinNT 4.0 maj=4 min=00
55 // IE 3.x, IE 4.0 without Web Integrated Desktop maj=4 min=00
56 // IE 4.0 with Web Integrated Desktop maj=4 min=71
57 // IE 4.01 with Web Integrated Desktop maj=4 min=72
58 // Win2000 maj=5 min=00
59 inline HRESULT GetShellVersion(
60 _Out_ LPDWORD pdwMajor,
61 _Out_ LPDWORD pdwMinor)
63 ATLENSURE(pdwMajor && pdwMinor);
65 DLLVERSIONINFO dvi = { 0 };
66 dvi.cbSize = sizeof(dvi);
67 HRESULT hRet = GetDllVersion(L"shell32.dll", &dvi);
69 if(SUCCEEDED(hRet))
71 *pdwMajor = dvi.dwMajorVersion;
72 *pdwMinor = dvi.dwMinorVersion;
75 return hRet;