1 /*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7 #ifndef INCLUDE_win32_version_h__
8 #define INCLUDE_win32_version_h__
9
10 #include <windows.h>
11
git_has_win32_version(int major,int minor,int service_pack)12 GIT_INLINE(int) git_has_win32_version(int major, int minor, int service_pack)
13 {
14 OSVERSIONINFOEX version_test = {0};
15 DWORD version_test_mask;
16 DWORDLONG version_condition_mask = 0;
17
18 version_test.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
19 version_test.dwMajorVersion = major;
20 version_test.dwMinorVersion = minor;
21 version_test.wServicePackMajor = (WORD)service_pack;
22 version_test.wServicePackMinor = 0;
23
24 version_test_mask = (VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR);
25
26 VER_SET_CONDITION(version_condition_mask, VER_MAJORVERSION, VER_GREATER_EQUAL);
27 VER_SET_CONDITION(version_condition_mask, VER_MINORVERSION, VER_GREATER_EQUAL);
28 VER_SET_CONDITION(version_condition_mask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
29 VER_SET_CONDITION(version_condition_mask, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL);
30
31 if (!VerifyVersionInfo(&version_test, version_test_mask, version_condition_mask))
32 return 0;
33
34 return 1;
35 }
36
37 #endif
38