summaryrefslogtreecommitdiff
path: root/zen/win_ver.h
blob: c2162c61d6663a35d1b4d58fbfe9c141347934c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// **************************************************************************
// * This file is part of the FreeFileSync project. It is distributed under *
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html       *
// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved    *
// **************************************************************************

#ifndef WINDOWS_VERSION_HEADER_238470348254325
#define WINDOWS_VERSION_HEADER_238470348254325

#include "win.h"

namespace zen
{
bool winXpOrLater();
bool winServer2003orLater();
bool vistaOrLater();
bool win7OrLater();












//######################### implementation #########################
//version overview: http://msdn.microsoft.com/en-us/library/ms724834(VS.85).aspx

//2000        is version 5.0
//XP          is version 5.1
//Server 2003 is version 5.2
//Vista       is version 6.0
//Seven       is version 6.1

namespace impl
{
inline
bool winXyOrLater(DWORD major, DWORD minor)
{
    OSVERSIONINFO osvi = {};
    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    if (::GetVersionEx(&osvi)) //38 ns per call! (yes, that's nano!) -> we do NOT miss C++11 thread safe statics right now...
        return osvi.dwMajorVersion > major ||
               (osvi.dwMajorVersion == major && osvi.dwMinorVersion >= minor);
    return false;
}
}

inline
bool winXpOrLater() { return impl::winXyOrLater(5, 1); }

inline
bool winServer2003orLater() { return impl::winXyOrLater(5, 2); }

inline
bool vistaOrLater() { return impl::winXyOrLater(6, 0); }

inline
bool win7OrLater() { return impl::winXyOrLater(6, 1); }
}

#endif //WINDOWS_VERSION_HEADER_238470348254325
bgstack15