Index: trunk/src/kernel32/registry.cpp
===================================================================
--- trunk/src/kernel32/registry.cpp	(revision 9643)
+++ trunk/src/kernel32/registry.cpp	(revision 9647)
@@ -1,3 +1,3 @@
-/* $Id: registry.cpp,v 1.19 2002-12-10 18:52:16 sandervl Exp $ */
+/* $Id: registry.cpp,v 1.20 2003-01-08 14:25:40 sandervl Exp $ */
 
 /*
@@ -853,5 +853,5 @@
 
   if((rc == ERROR_SUCCESS || rc == ERROR_MORE_DATA) && 
-     lpszValue == NULL && pcbValue) 
+     pcbValue) 
   {
       *pcbValue = *pcbValue * sizeof(WCHAR); //size in bytes!!
@@ -987,5 +987,5 @@
 
   if((rc == ERROR_SUCCESS || rc == ERROR_MORE_DATA) && 
-     lpbData == NULL && lpcbData) 
+     lpcbData) 
   {
       switch(*lpdwType) {
Index: trunk/src/kernel32/time.cpp
===================================================================
--- trunk/src/kernel32/time.cpp	(revision 9643)
+++ trunk/src/kernel32/time.cpp	(revision 9647)
@@ -1,3 +1,3 @@
-/* $Id: time.cpp,v 1.24 2003-01-03 11:26:43 sandervl Exp $ */
+/* $Id: time.cpp,v 1.25 2003-01-08 14:25:40 sandervl Exp $ */
 
 /*
@@ -183,68 +183,85 @@
 }
 //******************************************************************************
-//******************************************************************************
-DWORD TimeZoneName(LPSTR name, LPWSTR text, BOOL read)
-{
-    CHAR  AsciiText_1[32];
-    CHAR  AsciiText_2[32];
-    HKEY  hKeyOptions;
-    DWORD dwKeyType;
-    DWORD dwDataLength = sizeof(AsciiText_1);
-    DWORD dwDataLength_2;
-    BOOL  Set = FALSE;
-
-    if (read) {
-       ZeroMemory(text, 2*sizeof(AsciiText_1));
-    }
-    else {
-       UnicodeToAscii(text, &AsciiText_2[0]);
-       dwDataLength_2 = strlen(AsciiText_2);
-    }
-    DWORD rc = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
-                             "SOFTWARE\\TIME\\TIME_SETTING",
-                             0,
-                             (read) ? KEY_READ : KEY_ALL_ACCESS,
-                             &hKeyOptions);
-    if (rc == ERROR_SUCCESS) 
-    {
-        rc = RegQueryValueExA(hKeyOptions,
-                              name,
-                              0,
-                              &dwKeyType,
-                              (LPBYTE)AsciiText_1,
-                              &dwDataLength);
-        if (rc == ERROR_SUCCESS) {
-            if (read) AsciiToUnicode(&AsciiText_1[0], text);
-            else Set = (strcmp(AsciiText_1,AsciiText_2) != 0);
-        } 
-        else Set = (!read);
-    } 
-    else {
-        if (!read) {
-            rc = RegCreateKeyA(HKEY_LOCAL_MACHINE,
-                               "SOFTWARE\\TIME\\TIME_SETTING",
-                               &hKeyOptions);
-            Set = (rc == ERROR_SUCCESS);
-        }
-    }
-    if (Set) rc = RegSetValueExA(hKeyOptions,
-                                 name,
-                                 0,
-                                 REG_SZ,
-                                 (LPBYTE)AsciiText_2,
-                                 dwDataLength_2);
-
-    RegCloseKey(hKeyOptions);
-    return rc;
-}
+static const LPSTR szTZBias           = "Bias";
+static const LPSTR szTZActiveTimeBias = "ActiveTimeBias";
+
+static const LPWSTR szTZStandardName  = (LPWSTR)L"StandardName";
+static const LPSTR szTZStandardBias   = "StandardBias";
+static const LPSTR szTZStandardStart  = "StandardStart";
+
+static const LPWSTR szTZDaylightName  = (LPWSTR)L"DaylightName";
+static const LPSTR szTZDaylightBias   = "DaylightBias";
+static const LPSTR szTZDaylightStart  = "DaylightStart";
+static const LPSTR KEY_WINDOWS_TZ     = "SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation";
 //******************************************************************************
 DWORD WIN32API GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZone)
 {
-    DWORD ret = O32_GetTimeZoneInformation(lpTimeZone);
-
-    //Convert timezone names to unicode as WGSS (wrongly) returns ascii strings
-    TimeZoneName("STANDARD_NAME", &lpTimeZone->StandardName[0], TRUE);
-    TimeZoneName("DAYLIGHT_NAME", &lpTimeZone->DaylightName[0], TRUE);
-    return ret;
+    TIME_ZONE_INFORMATION tzone;
+    int len;
+
+    HKEY hkey;
+
+    if(RegCreateKeyA(HKEY_LOCAL_MACHINE, KEY_WINDOWS_TZ, &hkey) == ERROR_SUCCESS)
+    {
+        DWORD type, size;
+        DWORD rc;
+
+        size = sizeof(lpTimeZone->Bias);
+        rc = RegQueryValueExA(hkey, szTZBias,0,&type, (LPBYTE)&lpTimeZone->Bias, &size);
+        if(rc || type != REG_DWORD) {
+            goto fail;
+        }
+        size = sizeof(lpTimeZone->StandardName);
+        rc = RegQueryValueExW(hkey, szTZStandardName, 0, &type, (LPBYTE)lpTimeZone->StandardName, &size);
+        if(rc || type != REG_SZ) {
+            goto fail;
+        }
+        size = sizeof(lpTimeZone->StandardBias);
+        rc = RegQueryValueExA(hkey, szTZStandardBias,0,&type, (LPBYTE)&lpTimeZone->StandardBias, &size);
+        if(rc || type != REG_DWORD) {
+            goto fail;
+        }
+        size = sizeof(lpTimeZone->StandardDate);
+        rc = RegQueryValueExA(hkey, szTZStandardStart,0,&type, (LPBYTE)&lpTimeZone->StandardDate, &size);
+        if(rc || type != REG_BINARY) {
+            goto fail;
+        }
+
+        size = sizeof(lpTimeZone->DaylightName);
+        rc = RegQueryValueExW(hkey, szTZDaylightName, 0, &type, (LPBYTE)lpTimeZone->DaylightName, &size);
+        if(rc || type != REG_SZ) {
+            goto fail;
+        }
+        size = sizeof(lpTimeZone->DaylightBias);
+        rc = RegQueryValueExA(hkey, szTZDaylightBias,0,&type, (LPBYTE)&lpTimeZone->DaylightBias, &size);
+        if(rc || type != REG_DWORD) {
+            goto fail;
+        }
+        size = sizeof(lpTimeZone->DaylightDate);
+        rc = RegQueryValueExA(hkey, szTZDaylightStart,0,&type, (LPBYTE)&lpTimeZone->DaylightDate, &size);
+        if(rc || type != REG_BINARY) {
+            goto fail;
+        }
+        RegCloseKey(hkey);
+
+        //TODO: we should return whether or we are in standard or daylight time
+        return TIME_ZONE_ID_STANDARD;
+    }
+    else
+    {//get it from WGSS
+fail:
+        DWORD ret = O32_GetTimeZoneInformation(&tzone);
+
+        *lpTimeZone = tzone;
+
+        //Convert timezone names to unicode as WGSS (wrongly) returns ascii strings
+        len = sizeof(tzone.StandardName)/sizeof(WCHAR);
+        lstrcpynAtoW(lpTimeZone->StandardName, (LPSTR)tzone.StandardName, len);
+        lpTimeZone->StandardName[len] = 0;
+
+        lstrcpynAtoW(lpTimeZone->DaylightName, (LPSTR)tzone.DaylightName, len);
+        lpTimeZone->DaylightName[len] = 0;
+        return ret;
+    }
 }
 //******************************************************************************
@@ -252,9 +269,34 @@
 BOOL WIN32API SetTimeZoneInformation(const LPTIME_ZONE_INFORMATION lpTimeZone)
 {
+    TIME_ZONE_INFORMATION tzone = *lpTimeZone;
+    int len;
+    HKEY hkey;
+
+    if(RegCreateKeyA(HKEY_LOCAL_MACHINE, KEY_WINDOWS_TZ, &hkey) != ERROR_SUCCESS)
+    {
+        dprintf(("ERROR: SetTimeZoneInformation: Unable to create key"));
+        return FALSE;
+    }
+    RegSetValueExA(hkey, szTZBias,0,REG_DWORD, (LPBYTE)&lpTimeZone->Bias, sizeof(lpTimeZone->Bias));
+    RegSetValueExA(hkey, szTZActiveTimeBias,0,REG_DWORD, (LPBYTE)&lpTimeZone->Bias, sizeof(lpTimeZone->Bias));
+
+    RegSetValueExW(hkey, szTZStandardName, 0, REG_SZ, (LPBYTE)lpTimeZone->StandardName, lstrlenW(lpTimeZone->StandardName));
+    RegSetValueExA(hkey, szTZStandardBias,0,REG_DWORD, (LPBYTE)&lpTimeZone->StandardBias, sizeof(lpTimeZone->StandardBias));
+    RegSetValueExA(hkey, szTZStandardStart,0,REG_BINARY, (LPBYTE)&lpTimeZone->StandardDate, sizeof(lpTimeZone->StandardDate));
+
+    RegSetValueExW(hkey, szTZDaylightName, 0, REG_SZ, (LPBYTE)lpTimeZone->DaylightName, lstrlenW(lpTimeZone->DaylightName));
+    RegSetValueExA(hkey, szTZDaylightBias,0,REG_DWORD, (LPBYTE)&lpTimeZone->DaylightBias, sizeof(lpTimeZone->DaylightBias));
+    RegSetValueExA(hkey, szTZDaylightStart,0,REG_BINARY, (LPBYTE)&lpTimeZone->DaylightDate, sizeof(lpTimeZone->DaylightDate));
+    RegCloseKey(hkey);
+
     //Convert timezone names to ascii as WGSS (wrongly) expects that
-    TimeZoneName("STANDARD_NAME", &lpTimeZone->StandardName[0], FALSE);
-    TimeZoneName("DAYLIGHT_NAME", &lpTimeZone->DaylightName[0], FALSE);
-
-    return O32_SetTimeZoneInformation(lpTimeZone);
+    len = sizeof(tzone.StandardName)/sizeof(WCHAR);
+    lstrcpynWtoA((LPSTR)tzone.StandardName, lpTimeZone->StandardName, len);
+    tzone.StandardName[len] = 0;
+
+    lstrcpynWtoA((LPSTR)tzone.DaylightName, lpTimeZone->DaylightName, len);
+    tzone.DaylightName[len] = 0;
+
+    return O32_SetTimeZoneInformation(&tzone);
 }
 /*****************************************************************************
