diff options
author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2019-06-20 11:05:19 +0800 |
---|---|---|
committer | Chun-wei Fan <fanchunwei@src.gnome.org> | 2019-07-05 18:52:02 +0800 |
commit | 2e5d3aa91114ebc930393b74ff5a1af474c745bb (patch) | |
tree | 75db5c947f2f1597d72ae956477e7c636a2a67e1 | |
parent | c868123c0a499bbbbd9fffd966422a9e16be5419 (diff) | |
download | glib-2e5d3aa91114ebc930393b74ff5a1af474c745bb.tar.gz |
glib/gtimezone.c: Use RegLoadMUIStringW() to query Std/Dlt strings
The existing method of using RegQueryValueExW() to query the Std/Dlt
strings can only retrive the localized versions of those strings, so
that means they will vary by the language version of Windows. Instead,
use RegQueryValueExW() only as a fallback when RegLoadMUIStringW() fails,
as RegLoadMUIStringW() can query for the Std and Dlt strings in
whatever language we need by setting the locale stuff programatically on
the fly.
-rw-r--r-- | glib/gtimezone.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/glib/gtimezone.c b/glib/gtimezone.c index 751a925a1..4cc2d8d7f 100644 --- a/glib/gtimezone.c +++ b/glib/gtimezone.c @@ -729,8 +729,12 @@ rules_from_windows_time_zone (const gchar *identifier, DWORD size; guint rules_num = 0; RegTZI regtzi, regtzi_prev; + WCHAR winsyspath[MAX_PATH]; gunichar2 *subkey_w, *subkey_dynamic_w; + if (GetSystemDirectoryW (winsyspath, MAX_PATH) == 0) + return 0; + g_assert (out_identifier != NULL); g_assert (rules != NULL); @@ -758,18 +762,33 @@ rules_from_windows_time_zone (const gchar *identifier, if (RegOpenKeyExW (HKEY_LOCAL_MACHINE, subkey_w, 0, KEY_QUERY_VALUE, &key) != ERROR_SUCCESS) - return 0; + goto utf16_conv_failed; size = sizeof tzi.StandardName; - if (RegQueryValueExW (key, L"Std", NULL, NULL, - (LPBYTE)&(tzi.StandardName), &size) != ERROR_SUCCESS) - goto registry_failed; + + /* use RegLoadMUIStringW() to query MUI_Std from the registry if possible, otherwise + fallback to querying Std */ + if (RegLoadMUIStringW (key, L"MUI_Std", tzi.StandardName, + size, &size, 0, winsyspath) != ERROR_SUCCESS) + { + size = sizeof tzi.StandardName; + if (RegQueryValueExW (key, L"Std", NULL, NULL, + (LPBYTE)&(tzi.StandardName), &size) != ERROR_SUCCESS) + goto registry_failed; + } size = sizeof tzi.DaylightName; - if (RegQueryValueExW (key, L"Dlt", NULL, NULL, - (LPBYTE)&(tzi.DaylightName), &size) != ERROR_SUCCESS) - goto registry_failed; + /* use RegLoadMUIStringW() to query MUI_Dlt from the registry if possible, otherwise + fallback to querying Dlt */ + if (RegLoadMUIStringW (key, L"MUI_Dlt", tzi.DaylightName, + size, &size, 0, winsyspath) != ERROR_SUCCESS) + { + size = sizeof tzi.DaylightName; + if (RegQueryValueExW (key, L"Dlt", NULL, NULL, + (LPBYTE)&(tzi.DaylightName), &size) != ERROR_SUCCESS) + goto registry_failed; + } RegCloseKey (key); if (RegOpenKeyExW (HKEY_LOCAL_MACHINE, subkey_dynamic_w, 0, |