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



commit fad57fa732ea6212ac95dab25178620d3918294a
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Dec 22 17:23:52 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
    
    https://bugzilla.gnome.org/show_bug.cgi?id=741849

 gdk/win32/gdkmain-win32.c    |   14 ++++++++++++++
 gdk/win32/gdkprivate-win32.h |    3 +++
 2 files changed, 17 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
 
diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h
index acc3fca..9466a97 100644
--- a/gdk/win32/gdkprivate-win32.h
+++ b/gdk/win32/gdkprivate-win32.h
@@ -508,4 +508,7 @@ void _gdk_events_init (void);
 void _gdk_input_init  (GdkDisplay *display);
 void _gdk_input_wintab_init_check (GdkDeviceManager *device_manager);
 
+/* check OS version info */
+gboolean _gdk_win32_check_os_version (glong major, glong minor);
+
 #endif /* __GDK_PRIVATE_WIN32_H__ */


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