[gtk+/master.fcw: 315/648] gdkmain-win32.c: Add OS Info Check Function



commit 6a6172ea4a86d80dafec62a3ba34a3c365f03cdb
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Dec 22 16:55:53 2014 +0800

    gdkmain-win32.c: Add OS Info Check Function
    
    Add a private utility function that can be used to see whether we are on
    at least a specified version of Windows.  This is necessary as
    GetVersion()/GetVersionEx() are getting superceded in Windows 8.x, and
    would not necessarily return the actual version of Windows that the code is
    being run on [1].
    
    [1]: http://msdn.microsoft.com/zh-tw/library/windows/desktop/ms724451%28v=vs.85%29.aspx

 gdk/win32/gdkmain-win32.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/gdk/win32/gdkmain-win32.c b/gdk/win32/gdkmain-win32.c
index 905c729..3932245 100644
--- a/gdk/win32/gdkmain-win32.c
+++ b/gdk/win32/gdkmain-win32.c
@@ -150,6 +150,20 @@ _gdk_other_api_failed (const gchar *where,
   g_warning ("%s: %s failed", where, api);
 }
 
+gboolean
+_gdk_win32_check_os_version (glong major, glong minor)
+{
+  OSVERSIONINFOEXW osverinfo;
+  const DWORDLONG conds = VerSetConditionMask (VerSetConditionMask (0, VER_MAJORVERSION, VER_GREATER_EQUAL), 
VER_MINORVERSION, VER_GREATER_EQUAL);
+
+  memset (&osverinfo, 0, sizeof (OSVERSIONINFOEXW));
+  osverinfo.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEXW);
+  osverinfo.dwPlatformId = VER_PLATFORM_WIN32_NT;
+  osverinfo.dwMajorVersion = major;
+  osverinfo.dwMinorVersion = minor;
+
+  return VerifyVersionInfoW (&osverinfo, VER_MAJORVERSION | VER_MINORVERSION, conds);
+}
 
 #ifdef G_ENABLE_DEBUG
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]