[PATCH 2/2] kernel32: Autoinitialize geographic values when launching any program.
João Diogo Ferreira
devilj at outlook.pt
Mon Nov 18 08:36:56 CST 2019
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46196
Signed-off-by: João Diogo Craveiro Ferreira <devilj at outlook.pt>
---
V8: Use a fallback in case we don't get the right nation ID.
Supersedes: 173826
---
dlls/kernel32/kernel_main.c | 3 +++
dlls/kernel32/kernel_private.h | 1 +
dlls/kernel32/locale.c | 12 ++++++++++++
3 files changed, 16 insertions(+)
diff --git a/dlls/kernel32/kernel_main.c b/dlls/kernel32/kernel_main.c
index dfa66f0295..206972c210 100644
--- a/dlls/kernel32/kernel_main.c
+++ b/dlls/kernel32/kernel_main.c
@@ -88,6 +88,9 @@ static BOOL process_attach( HMODULE module )
/* Setup registry locale information */
LOCALE_InitRegistry();
+ /* Setup registry geographic information */
+ LOCALE_InitGeo();
+
/* Setup registry timezone information */
TIMEZONE_InitRegistry();
diff --git a/dlls/kernel32/kernel_private.h b/dlls/kernel32/kernel_private.h
index cd6c63efa3..e9f5f51029 100644
--- a/dlls/kernel32/kernel_private.h
+++ b/dlls/kernel32/kernel_private.h
@@ -75,6 +75,7 @@ extern void COMPUTERNAME_Init(void) DECLSPEC_HIDDEN;
/* locale.c */
extern void LOCALE_Init(void) DECLSPEC_HIDDEN;
extern void LOCALE_InitRegistry(void) DECLSPEC_HIDDEN;
+extern void LOCALE_InitGeo(void) DECLSPEC_HIDDEN;
/* time.c */
extern void TIMEZONE_InitRegistry(void) DECLSPEC_HIDDEN;
diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c
index 0f91728e84..208c792e39 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -845,6 +845,18 @@ void LOCALE_InitRegistry(void)
NtClose( hkey );
}
+/* Initialize the geographic information in the registry. */
+void LOCALE_InitGeo(void)
+{
+ GEOID id = GEOID_NOT_AVAILABLE;
+ static const GEOID fallback = 244; /* United States */
+
+ GetLocaleInfoW(GetUserDefaultLCID(), LOCALE_IGEOID|LOCALE_RETURN_NUMBER,
+ (WCHAR *)&id, sizeof(id) / sizeof(WCHAR));
+
+ if (!SetUserGeoID(id) || GetUserGeoID(GEOCLASS_NATION) == GEOID_NOT_AVAILABLE)
+ SetUserGeoID(fallback);
+}
#ifdef __APPLE__
/***********************************************************************
--
2.24.0
More information about the wine-devel
mailing list