1fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill/*
2fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill * Copyright (C) 2009 Apple Inc. All Rights Reserved.
3fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill *
4fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill * Redistribution and use in source and binary forms, with or without
5fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill * modification, are permitted provided that the following conditions
6fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill * are met:
7fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill * 1. Redistributions of source code must retain the above copyright
8fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill *    notice, this list of conditions and the following disclaimer.
9fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill * 2. Redistributions in binary form must reproduce the above copyright
10fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill *    notice, this list of conditions and the following disclaimer in the
11fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill *    documentation and/or other materials provided with the distribution.
12fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill *
13fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill */
25fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill
26d61e4726c4f632bf5803435a583bd631db066426Jamie Madill#include <windows.h>
27d61e4726c4f632bf5803435a583bd631db066426Jamie Madill
28fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill#if _WIN32_WINNT_WINBLUE
29fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill#include <versionhelpers.h>
30fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill#endif
31fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill
32fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madillnamespace rx {
33fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill
34fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill#ifndef _WIN32_WINNT_WINBLUE
35fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madillstatic bool IsWindowsVistaOrGreater()
36fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill{
37fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill    OSVERSIONINFOEXW osvi = { };
38fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill    osvi.dwOSVersionInfoSize = sizeof(osvi);
39fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill    osvi.dwMajorVersion = HIBYTE(_WIN32_WINNT_VISTA);
40fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill    osvi.dwMinorVersion = LOBYTE(_WIN32_WINNT_VISTA);
41fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill    DWORDLONG condition = 0;
42fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill    VER_SET_CONDITION(condition, VER_MAJORVERSION, VER_GREATER_EQUAL);
43fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill    VER_SET_CONDITION(condition, VER_MINORVERSION, VER_GREATER_EQUAL);
44fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill    return !!::VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION, condition);
45fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill}
46fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill#endif
47fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill
48fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madillbool isWindowsVistaOrGreater()
49fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill{
50fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill    static bool initialized = false;
51fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill    static bool cachedIsWindowsVistaOrGreater;
52fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill
53fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill    if (!initialized) {
54fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill        initialized = true;
55fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill        cachedIsWindowsVistaOrGreater = IsWindowsVistaOrGreater();
56fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill    }
57fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill    return cachedIsWindowsVistaOrGreater;
58fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill}
59fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill
60fc2521e16b341ab11eb413b44f7e8656d40f1c7cJamie Madill} // namespace rx
61