diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c index 528f945513f..a2f369a1f71 100644 --- a/dlls/kernel32/locale.c +++ b/dlls/kernel32/locale.c @@ -1048,35 +1048,17 @@ INT WINAPI GetSystemDefaultLocaleName(LPWSTR localename, INT len) return LCIDToLocaleName(lcid, localename, len, 0); } -/*********************************************************************** - * GetSystemPreferredUILanguages (KERNEL32.@) - */ -BOOL WINAPI GetSystemPreferredUILanguages(DWORD flags, ULONG* count, WCHAR* buffer, ULONG* size) +static BOOL get_dummy_preferred_ui_language( DWORD flags, ULONG *count, WCHAR *buffer, ULONG *size ) { LCTYPE type; int lsize; - if (flags & ~(MUI_LANGUAGE_NAME | MUI_LANGUAGE_ID | MUI_MACHINE_LANGUAGE_SETTINGS)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - if ((flags & MUI_LANGUAGE_NAME) && (flags & MUI_LANGUAGE_ID)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - if (*size && !buffer) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } FIXME("(0x%x %p %p %p) returning a dummy value (current locale)\n", flags, count, buffer, size); if (flags & MUI_LANGUAGE_ID) - type = LOCALE_ILANGUAGE; - else - type = LOCALE_SNAME; + type = LOCALE_ILANGUAGE; + else + type = LOCALE_SNAME; lsize = GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT, type, NULL, 0); if (!lsize) @@ -1109,6 +1091,49 @@ BOOL WINAPI GetSystemPreferredUILanguages(DWORD flags, ULONG* count, WCHAR* buff *count = 1; TRACE("returned variable content: %d, \"%s\", %d\n", *count, debugstr_w(buffer), *size); return TRUE; + +} + +/*********************************************************************** + * GetSystemPreferredUILanguages (KERNEL32.@) + */ +BOOL WINAPI GetSystemPreferredUILanguages(DWORD flags, ULONG* count, WCHAR* buffer, ULONG* size) +{ + if (flags & ~(MUI_LANGUAGE_NAME | MUI_LANGUAGE_ID | MUI_MACHINE_LANGUAGE_SETTINGS)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + if ((flags & MUI_LANGUAGE_NAME) && (flags & MUI_LANGUAGE_ID)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + if (*size && !buffer) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + return get_dummy_preferred_ui_language( flags, count, buffer, size ); +} + +/*********************************************************************** + * SetThreadPreferredUILanguages (KERNEL32.@) + */ +BOOL WINAPI SetThreadPreferredUILanguages( DWORD flags, PCZZWSTR buffer, PULONG count ) +{ + FIXME( "%u, %p, %p\n", flags, buffer, count ); + return TRUE; +} + +/*********************************************************************** + * GetThreadPreferredUILanguages (KERNEL32.@) + */ +BOOL WINAPI GetThreadPreferredUILanguages( DWORD flags, ULONG *count, WCHAR *buf, ULONG *size ) +{ + FIXME( "%08x, %p, %p %p\n", flags, count, buf, size ); + return get_dummy_preferred_ui_language( flags, count, buf, size ); } /*********************************************************************** diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c index 57dc418d7e7..20f52d26771 100644 --- a/dlls/kernel32/tests/locale.c +++ b/dlls/kernel32/tests/locale.c @@ -98,6 +98,7 @@ static INT (WINAPI *pGetGeoInfoA)(GEOID, GEOTYPE, LPSTR, INT, LANGID); static INT (WINAPI *pGetGeoInfoW)(GEOID, GEOTYPE, LPWSTR, INT, LANGID); static BOOL (WINAPI *pEnumSystemGeoID)(GEOCLASS, GEOID, GEO_ENUMPROC); static BOOL (WINAPI *pGetSystemPreferredUILanguages)(DWORD, ULONG*, WCHAR*, ULONG*); +static BOOL (WINAPI *pGetThreadPreferredUILanguages)(DWORD, ULONG*, WCHAR*, ULONG*); static void InitFunctionPointers(void) { @@ -127,6 +128,7 @@ static void InitFunctionPointers(void) X(GetGeoInfoW); X(EnumSystemGeoID); X(GetSystemPreferredUILanguages); + X(GetThreadPreferredUILanguages); #undef X } @@ -4770,6 +4772,32 @@ static void test_GetSystemPreferredUILanguages(void) "Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); } +static void test_GetThreadPreferredUILanguages(void) +{ + BOOL ret; + ULONG count, size; + WCHAR *buf; + + if (!pGetThreadPreferredUILanguages) + { + win_skip("GetThreadPreferredUILanguages is not available.\n"); + return; + } + + size = count = 0; + ret = pGetThreadPreferredUILanguages(MUI_LANGUAGE_ID|MUI_UI_FALLBACK, &count, NULL, &size); + ok(ret, "got %u\n", GetLastError()); + ok(count, "expected count > 0\n"); + ok(size, "expected size > 0\n"); + + count = 0; + buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size * sizeof(WCHAR)); + ret = pGetThreadPreferredUILanguages(MUI_LANGUAGE_ID|MUI_UI_FALLBACK, &count, buf, &size); + ok(ret, "got %u\n", GetLastError()); + ok(count, "expected count > 0\n"); + HeapFree(GetProcessHeap(), 0, buf); +} + START_TEST(locale) { InitFunctionPointers(); @@ -4813,6 +4841,7 @@ START_TEST(locale) test_EnumSystemGeoID(); test_invariant(); test_GetSystemPreferredUILanguages(); + test_GetThreadPreferredUILanguages(); /* this requires collation table patch to make it MS compatible */ if (0) test_sorting(); } diff --git a/dlls/kernel32/thread.c b/dlls/kernel32/thread.c index 0e9de820308..6630e7fd0dc 100644 --- a/dlls/kernel32/thread.c +++ b/dlls/kernel32/thread.c @@ -887,26 +887,6 @@ BOOL WINAPI GetThreadIOPendingFlag( HANDLE thread, PBOOL io_pending ) return TRUE; } -/*********************************************************************** - * SetThreadPreferredUILanguages (KERNEL32.@) - */ -BOOL WINAPI SetThreadPreferredUILanguages( DWORD flags, PCZZWSTR buffer, PULONG count ) -{ - FIXME( "%u, %p, %p\n", flags, buffer, count ); - return TRUE; -} - -/*********************************************************************** - * GetThreadPreferredUILanguages (KERNEL32.@) - */ -BOOL WINAPI GetThreadPreferredUILanguages( DWORD flags, PULONG count, PCZZWSTR buffer, PULONG buffersize ) -{ - FIXME( "%u, %p, %p %p\n", flags, count, buffer, buffersize ); - *count = 0; - *buffersize = 0; - return TRUE; -} - /*********************************************************************** * CallbackMayRunLong (KERNEL32.@) */ diff --git a/include/winnls.h b/include/winnls.h index 6e5897b22e7..1a7baaf04ee 100644 --- a/include/winnls.h +++ b/include/winnls.h @@ -909,6 +909,7 @@ WINBASEAPI LCID WINAPI GetSystemDefaultLCID(void); WINBASEAPI LANGID WINAPI GetSystemDefaultUILanguage(void); WINBASEAPI BOOL WINAPI GetSystemPreferredUILanguages(DWORD,ULONG*,WCHAR*,ULONG*); WINBASEAPI LCID WINAPI GetThreadLocale(void); +WINBASEAPI BOOL WINAPI GetThreadPreferredUILanguages(DWORD,ULONG*,WCHAR*,ULONG*); WINBASEAPI INT WINAPI GetTimeFormatA(LCID,DWORD,const SYSTEMTIME*,LPCSTR,LPSTR,INT); WINBASEAPI INT WINAPI GetTimeFormatEx(LPCWSTR,DWORD,const SYSTEMTIME*,LPCWSTR,LPWSTR,INT); WINBASEAPI INT WINAPI GetTimeFormatW(LCID,DWORD,const SYSTEMTIME*,LPCWSTR,LPWSTR,INT);