summaryrefslogtreecommitdiffstatshomepage
path: root/src/os.hpp
blob: 20811f929d11954acafbba3d15cd3aad315b1169 (plain) (blame)
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
// Copyright (c) 2016 Egor Tensin <egor@tensin.name>
// This file is part of the "Privilege check" project.
// For details, see https://github.com/egor-tensin/privilege-check.
// Distributed under the MIT License.

#pragma once

#include "error.hpp"

#include <windows.h>

namespace os {

inline OSVERSIONINFOW get_version_info() {
    OSVERSIONINFOW info;
    ZeroMemory(&info, sizeof(info));
    info.dwOSVersionInfoSize = sizeof(info);

    if (!GetVersionExW(&info))
        error::raise("GetVersionExW");

    return info;
}

inline bool is_vista_or_later(const OSVERSIONINFOW& info) {
    return info.dwMajorVersion >= 6;
}

inline bool is_vista_or_later() {
    return is_vista_or_later(get_version_info());
}

} // namespace os