version.h 1.25 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/*
 * Copyright (C) the libgit2 contributors. All rights reserved.
 *
 * This file is part of libgit2, distributed under the GNU GPL v2 with
 * a Linking Exception. For full terms see the included COPYING file.
 */
#ifndef INCLUDE_win32_version_h__
#define INCLUDE_win32_version_h__

#include <windows.h>

12
GIT_INLINE(int) git_has_win32_version(int major, int minor, int service_pack)
13
{
14 15 16 17 18 19 20
	OSVERSIONINFOEX version_test = {0};
	DWORD version_test_mask;
	DWORDLONG version_condition_mask = 0;
	
	version_test.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
	version_test.dwMajorVersion = major;
	version_test.dwMinorVersion = minor;
21
	version_test.wServicePackMajor = (WORD)service_pack;
22
	version_test.wServicePackMinor = 0;
23

24 25 26 27 28 29 30 31 32 33 34
	version_test_mask = (VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR);

	VER_SET_CONDITION(version_condition_mask, VER_MAJORVERSION, VER_GREATER_EQUAL);
	VER_SET_CONDITION(version_condition_mask, VER_MINORVERSION, VER_GREATER_EQUAL);
	VER_SET_CONDITION(version_condition_mask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
	VER_SET_CONDITION(version_condition_mask, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL);

	if (!VerifyVersionInfo(&version_test, version_test_mask, version_condition_mask))
		return 0;

	return 1;
35 36
}

37
#endif