Handle versioncheck.tortoisegit.org as official source
[TortoiseGit.git] / src / Utils / DllVersion.h
blobfe46532d640d898724b202cda9c271fb15772e37
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 != NULL);
32 // We must get this function explicitly because some DLLs don't implement it.
33 DLLGETVERSIONPROC pfnDllGetVersion = (DLLGETVERSIONPROC)::GetProcAddress(hInstDLL, "DllGetVersion");
35 if(pfnDllGetVersion == NULL)
37 return E_NOTIMPL;
40 return (*pfnDllGetVersion)(pDllVersionInfo);
43 inline HRESULT GetDllVersion(
44 _In_z_ LPCTSTR lpstrDllName,
45 _Out_ DLLVERSIONINFO* pDllVersionInfo)
47 HINSTANCE hInstDLL = ::LoadLibrary(lpstrDllName);
48 if(hInstDLL == NULL)
50 return AtlHresultFromLastError();
52 HRESULT hRet = GetDllVersion(hInstDLL, pDllVersionInfo);
53 ::FreeLibrary(hInstDLL);
54 return hRet;
57 // Shell Versions:
58 // WinNT 4.0 maj=4 min=00
59 // IE 3.x, IE 4.0 without Web Integrated Desktop maj=4 min=00
60 // IE 4.0 with Web Integrated Desktop maj=4 min=71
61 // IE 4.01 with Web Integrated Desktop maj=4 min=72
62 // Win2000 maj=5 min=00
63 inline HRESULT GetShellVersion(
64 _Out_ LPDWORD pdwMajor,
65 _Out_ LPDWORD pdwMinor)
67 ATLENSURE(( pdwMajor != NULL) && ( pdwMinor != NULL ));
69 DLLVERSIONINFO dvi;
70 memset(&dvi, 0, sizeof(dvi));
71 dvi.cbSize = sizeof(dvi);
72 HRESULT hRet = GetDllVersion(_T("shell32.dll"), &dvi);
74 if(SUCCEEDED(hRet))
76 *pdwMajor = dvi.dwMajorVersion;
77 *pdwMinor = dvi.dwMinorVersion;
80 return hRet;