From 0062a3a42f6aee6260b2733823c7c586122ef3fc Mon Sep 17 00:00:00 2001
From: Geoffroy Couprie <geo.couprie@gmail.com>
Date: Wed, 4 Jun 2008 19:09:43 +0200
Subject: [PATCH] replace GetVersion by GetVersionEx

---
 src/text/unicode.c |   37 ++++++++++++++++++++++++++++++-------
 1 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/src/text/unicode.c b/src/text/unicode.c
index 7b9b1d7..0e1a90c 100644
--- a/src/text/unicode.c
+++ b/src/text/unicode.c
@@ -45,6 +45,8 @@
 #endif
 #ifdef UNDER_CE
 #  include <tchar.h>
+#  include <winbase.h>
+#  include <winnt.h>
 #endif
 #ifdef HAVE_SYS_STAT_H
 # include <sys/stat.h>
@@ -265,8 +267,15 @@ char *ToLocaleDup (const char *utf8)
  */
 int utf8_open (const char *filename, int flags, mode_t mode)
 {
-#if defined (WIN32) || defined (UNDER_CE)
-    if (GetVersion() < 0x80000000)
+#if defined (WIN32)
+    OSVERSIONINFO osinf;
+
+    ZeroMemory(&osinf, sizeof(OSVERSIONINFO));
+    osinf.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+
+    GetVersionEx(&osinf);
+
+    if(osinf.dwPlatformId == VER_PLATFORM_WIN32_NT || osinf.dwPlatformId == VER_PLATFORM_WIN32_CE)
     {
         /* for Windows NT and above */
         wchar_t wpath[MAX_PATH + 1];
@@ -284,6 +293,7 @@ int utf8_open (const char *filename, int flags, mode_t mode)
          */
         return _wopen (wpath, flags, mode);
     }
+
 #endif
     const char *local_name = ToLocale (filename);
 
@@ -576,9 +586,15 @@ int utf8_scandir( const char *dirname, char ***namelist,
 static int utf8_statEx( const char *filename, struct stat *buf,
                         bool deref )
 {
-#if defined (WIN32) || defined (UNDER_CE)
-    /* retrieve Windows OS version */
-    if( GetVersion() < 0x80000000 )
+#if defined (WIN32)
+    OSVERSIONINFO osinf;
+
+    ZeroMemory(&osinf, sizeof(OSVERSIONINFO));
+    osinf.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+
+    GetVersionEx(&osinf);
+
+    if(osinf.dwPlatformId == VER_PLATFORM_WIN32_NT || osinf.dwPlatformId == VER_PLATFORM_WIN32_CE)
     {
         /* for Windows NT and above */
         wchar_t wpath[MAX_PATH + 1];
@@ -639,8 +655,15 @@ int utf8_lstat( const char *filename, struct stat *buf)
  */
 int utf8_unlink( const char *filename )
 {
-#if defined (WIN32) || defined (UNDER_CE)
-    if( GetVersion() < 0x80000000 )
+#if defined (WIN32)
+    OSVERSIONINFO osinf;
+
+    ZeroMemory(&osinf, sizeof(OSVERSIONINFO));
+    osinf.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+
+    GetVersionEx(&osinf);
+
+    if(osinf.dwPlatformId == VER_PLATFORM_WIN32_NT || osinf.dwPlatformId == VER_PLATFORM_WIN32_CE)
     {
         /* for Windows NT and above */
         wchar_t wpath[MAX_PATH + 1];
-- 
1.5.5.1

