1 /* 2 * Copyright 2019-2019 Blender Foundation 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifdef _WIN32 18 # include <windows.h> 19 #endif 20 21 #include "util_windows.h" 22 23 CCL_NAMESPACE_BEGIN 24 system_windows_version_at_least(int major,int build)25bool system_windows_version_at_least(int major, int build) 26 { 27 #ifdef _WIN32 28 HMODULE hMod = ::GetModuleHandleW(L"ntdll.dll"); 29 if (hMod == 0) { 30 return false; 31 } 32 33 typedef NTSTATUS(WINAPI * RtlGetVersionPtr)(PRTL_OSVERSIONINFOW); 34 RtlGetVersionPtr rtl_get_version = (RtlGetVersionPtr)::GetProcAddress(hMod, "RtlGetVersion"); 35 if (rtl_get_version == NULL) { 36 return false; 37 } 38 39 RTL_OSVERSIONINFOW rovi = {0}; 40 rovi.dwOSVersionInfoSize = sizeof(rovi); 41 if (rtl_get_version(&rovi) != 0) { 42 return false; 43 } 44 45 return (rovi.dwMajorVersion > major || 46 (rovi.dwMajorVersion == major && rovi.dwBuildNumber >= build)); 47 #else 48 (void)major; 49 (void)build; 50 return false; 51 #endif 52 } 53 54 CCL_NAMESPACE_END 55