aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/src/os.hpp
blob: 6734fb4d14c6bee9275b0ff02414a25fa99cfcb5 (plain) (tree)
1
2
3
4
5
6
7
8
                                                         

                                                                   

                                     

            
                    




                    










                                                
 
                                                             



                                        
                                   



                                                     
// Copyright (c) 2016 Egor Tensin <Egor.Tensin@gmail.com>
// 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());
    }
}