mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 21:56:06 +00:00
Implement GetSystemDefaultUILanguage() and IsValidLocale().
svn path=/trunk/; revision=11911
This commit is contained in:
parent
181afb23d6
commit
98ac389c31
2 changed files with 198 additions and 106 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: lang.c,v 1.24 2004/10/20 03:46:27 jimtabor Exp $
|
/* $Id: lang.c,v 1.25 2004/12/04 13:59:14 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT : ReactOS user mode libraries
|
* PROJECT : ReactOS user mode libraries
|
||||||
|
@ -42,35 +42,36 @@
|
||||||
* GetUserDefaultLCID(), if lcid == LOCALE_USER_DEFAULT or LOCALE_NEUTRAL.
|
* GetUserDefaultLCID(), if lcid == LOCALE_USER_DEFAULT or LOCALE_NEUTRAL.
|
||||||
* Otherwise, lcid with sublanguage changed to SUBLANG_DEFAULT.
|
* Otherwise, lcid with sublanguage changed to SUBLANG_DEFAULT.
|
||||||
*/
|
*/
|
||||||
LCID WINAPI ConvertDefaultLocale( LCID lcid )
|
LCID WINAPI
|
||||||
|
ConvertDefaultLocale(LCID lcid)
|
||||||
{
|
{
|
||||||
LANGID langid;
|
LANGID langid;
|
||||||
|
|
||||||
switch (lcid)
|
switch (lcid)
|
||||||
{
|
{
|
||||||
case LOCALE_SYSTEM_DEFAULT:
|
case LOCALE_SYSTEM_DEFAULT:
|
||||||
lcid = GetSystemDefaultLCID();
|
lcid = GetSystemDefaultLCID();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LOCALE_USER_DEFAULT:
|
case LOCALE_USER_DEFAULT:
|
||||||
case LOCALE_NEUTRAL:
|
case LOCALE_NEUTRAL:
|
||||||
lcid = GetUserDefaultLCID();
|
lcid = GetUserDefaultLCID();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* Replace SUBLANG_NEUTRAL with SUBLANG_DEFAULT */
|
/* Replace SUBLANG_NEUTRAL with SUBLANG_DEFAULT */
|
||||||
langid = LANGIDFROMLCID(lcid);
|
langid = LANGIDFROMLCID(lcid);
|
||||||
if (SUBLANGID(langid) == SUBLANG_NEUTRAL)
|
if (SUBLANGID(langid) == SUBLANG_NEUTRAL)
|
||||||
{
|
{
|
||||||
langid = MAKELANGID(PRIMARYLANGID(langid), SUBLANG_DEFAULT);
|
langid = MAKELANGID(PRIMARYLANGID(langid), SUBLANG_DEFAULT);
|
||||||
lcid = MAKELCID(langid, SORTIDFROMLCID(lcid));
|
lcid = MAKELCID(langid, SORTIDFROMLCID(lcid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lcid;
|
|
||||||
|
return lcid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
|
@ -240,7 +241,7 @@ EnumSystemGeoID(
|
||||||
BOOL
|
BOOL
|
||||||
STDCALL
|
STDCALL
|
||||||
EnumSystemLanguageGroupsA(
|
EnumSystemLanguageGroupsA(
|
||||||
LANGUAGEGROUP_ENUMPROCA lpLanguageGroupEnumProc,
|
LANGUAGEGROUP_ENUMPROCA pLangGroupEnumProc,
|
||||||
DWORD dwFlags,
|
DWORD dwFlags,
|
||||||
LONG_PTR lParam)
|
LONG_PTR lParam)
|
||||||
{
|
{
|
||||||
|
@ -254,8 +255,23 @@ EnumSystemLanguageGroupsA(
|
||||||
*/
|
*/
|
||||||
BOOL
|
BOOL
|
||||||
STDCALL
|
STDCALL
|
||||||
EnumSystemLocalesW (
|
EnumSystemLanguageGroupsW(
|
||||||
LOCALE_ENUMPROCW lpLocaleEnumProc,
|
LANGUAGEGROUP_ENUMPROCW pLangGroupEnumProc,
|
||||||
|
DWORD dwFlags,
|
||||||
|
LONG_PTR lParam)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @unimplemented
|
||||||
|
*/
|
||||||
|
BOOL
|
||||||
|
STDCALL
|
||||||
|
EnumSystemLocalesA (
|
||||||
|
LOCALE_ENUMPROCA lpLocaleEnumProc,
|
||||||
DWORD dwFlags
|
DWORD dwFlags
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -269,8 +285,8 @@ EnumSystemLocalesW (
|
||||||
*/
|
*/
|
||||||
BOOL
|
BOOL
|
||||||
STDCALL
|
STDCALL
|
||||||
EnumSystemLocalesA (
|
EnumSystemLocalesW (
|
||||||
LOCALE_ENUMPROCA lpLocaleEnumProc,
|
LOCALE_ENUMPROCW lpLocaleEnumProc,
|
||||||
DWORD dwFlags
|
DWORD dwFlags
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -877,47 +893,52 @@ INT STDCALL GetLocaleInfoA( LCID lcid, LCTYPE lctype, LPSTR buffer, INT len )
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
LANGID
|
LANGID STDCALL
|
||||||
STDCALL
|
GetSystemDefaultLangID(VOID)
|
||||||
GetSystemDefaultLangID (VOID)
|
|
||||||
{
|
{
|
||||||
return LANGIDFROMLCID(GetSystemDefaultLCID());
|
return LANGIDFROMLCID(GetSystemDefaultLCID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
LCID
|
LCID STDCALL
|
||||||
STDCALL
|
GetSystemDefaultLCID(VOID)
|
||||||
GetSystemDefaultLCID (VOID)
|
|
||||||
{
|
{
|
||||||
LCID lcid;
|
LCID lcid;
|
||||||
NtQueryDefaultLocale( FALSE, &lcid );
|
|
||||||
return lcid;
|
|
||||||
|
|
||||||
// return SystemLocale;
|
NtQueryDefaultLocale(FALSE, &lcid);
|
||||||
|
|
||||||
|
return lcid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
LANGID
|
LANGID STDCALL
|
||||||
STDCALL
|
|
||||||
GetSystemDefaultUILanguage(VOID)
|
GetSystemDefaultUILanguage(VOID)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
LANGID LanguageId;
|
||||||
return 0;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
Status = NtQueryInstallUILanguage(&LanguageId);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return LanguageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
LCID
|
LCID STDCALL
|
||||||
STDCALL
|
GetThreadLocale(VOID)
|
||||||
GetThreadLocale (VOID)
|
|
||||||
{
|
{
|
||||||
return NtCurrentTeb()->CurrentLocale;
|
return NtCurrentTeb()->CurrentLocale;
|
||||||
}
|
}
|
||||||
|
@ -926,53 +947,50 @@ GetThreadLocale (VOID)
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
LANGID
|
LANGID STDCALL
|
||||||
STDCALL
|
GetUserDefaultLangID(VOID)
|
||||||
GetUserDefaultLangID (VOID)
|
|
||||||
{
|
{
|
||||||
return LANGIDFROMLCID(GetUserDefaultLCID());
|
return LANGIDFROMLCID(GetUserDefaultLCID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
LCID
|
LCID STDCALL
|
||||||
STDCALL
|
GetUserDefaultLCID(VOID)
|
||||||
GetUserDefaultLCID (VOID)
|
|
||||||
{
|
{
|
||||||
LCID lcid;
|
LCID lcid;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
Status = NtQueryDefaultLocale(TRUE, &lcid);
|
Status = NtQueryDefaultLocale(TRUE, &lcid);
|
||||||
if(!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return lcid;
|
return lcid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
LANGID
|
LANGID STDCALL
|
||||||
STDCALL
|
|
||||||
GetUserDefaultUILanguage(VOID)
|
GetUserDefaultUILanguage(VOID)
|
||||||
{
|
{
|
||||||
LANGID LangId;
|
LANGID LangId;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
Status = NtQueryDefaultUILanguage(&LangId);
|
Status = NtQueryDefaultUILanguage(&LangId);
|
||||||
if(!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return LangId;
|
return LangId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1003,36 +1021,124 @@ IsValidLanguageGroup(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* @implemented
|
* IsValidLocale
|
||||||
* RIPPED FROM WINE's dlls\kernel\locale.c rev 1.44
|
|
||||||
*
|
|
||||||
* IsValidLocale (KERNEL32.@)
|
|
||||||
*
|
*
|
||||||
* Determine if a locale is valid.
|
* Determine if a locale is valid.
|
||||||
*
|
*
|
||||||
* PARAMS
|
* PARAMS
|
||||||
* lcid [I] LCID of the locale to check
|
* Locale [I] LCID of the locale to check
|
||||||
* flags [I] LCID_SUPPORTED = Valid, LCID_INSTALLED = Valid and installed on the system
|
* dwFlags [I] LCID_SUPPORTED = Valid
|
||||||
|
* LCID_INSTALLED = Valid and installed on the system
|
||||||
*
|
*
|
||||||
* RETURN
|
* RETURN
|
||||||
* TRUE, if lcid is valid,
|
* TRUE, if Locale is valid,
|
||||||
* FALSE, otherwise.
|
* FALSE, otherwise.
|
||||||
*
|
*
|
||||||
* NOTES
|
* @implemented
|
||||||
* Wine does not currently make the distinction between supported and installed. All
|
|
||||||
* languages supported are installed by default.
|
|
||||||
*/
|
*/
|
||||||
BOOL STDCALL
|
BOOL STDCALL
|
||||||
IsValidLocale(
|
IsValidLocale(LCID Locale,
|
||||||
LCID lcid,
|
DWORD dwFlags)
|
||||||
DWORD flags
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
/* check if language is registered in the kernel32 resources */
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
return FindResourceExW( hCurrentModule, (LPWSTR)RT_STRING,
|
PKEY_VALUE_PARTIAL_INFORMATION KeyInfo;
|
||||||
(LPCWSTR)LOCALE_ILANGUAGE, LANGIDFROMLCID(lcid)) != 0;
|
WCHAR ValueNameBuffer[9];
|
||||||
|
UNICODE_STRING KeyName;
|
||||||
|
UNICODE_STRING ValueName;
|
||||||
|
ULONG KeyInfoSize;
|
||||||
|
ULONG ReturnedSize;
|
||||||
|
HANDLE KeyHandle;
|
||||||
|
PWSTR ValueData;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT("IsValidLocale() called\n");
|
||||||
|
|
||||||
|
if ((dwFlags & ~(LCID_SUPPORTED | LCID_INSTALLED)) ||
|
||||||
|
(dwFlags == (LCID_SUPPORTED | LCID_INSTALLED)))
|
||||||
|
{
|
||||||
|
DPRINT("Invalid flags: %lx\n", dwFlags);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Locale & 0xFFFF0000)
|
||||||
|
{
|
||||||
|
RtlInitUnicodeString(&KeyName,
|
||||||
|
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\Nls\\Locale\\Alternate Sorts");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RtlInitUnicodeString(&KeyName,
|
||||||
|
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\Nls\\Locale");
|
||||||
|
}
|
||||||
|
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&KeyName,
|
||||||
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
Status = NtOpenKey(&KeyHandle,
|
||||||
|
KEY_QUERY_VALUE,
|
||||||
|
&ObjectAttributes);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT("NtOpenKey() failed (Status %lx)\n", Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
swprintf(ValueNameBuffer, L"%08lx", (ULONG)Locale);
|
||||||
|
RtlInitUnicodeString(&ValueName, ValueNameBuffer);
|
||||||
|
|
||||||
|
KeyInfoSize = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 4 * sizeof(WCHAR);
|
||||||
|
KeyInfo = RtlAllocateHeap(RtlGetProcessHeap(),
|
||||||
|
HEAP_ZERO_MEMORY,
|
||||||
|
KeyInfoSize);
|
||||||
|
if (KeyInfo == NULL)
|
||||||
|
{
|
||||||
|
DPRINT("RtlAllocateHeap() failed (Status %lx)\n", Status);
|
||||||
|
NtClose(KeyHandle);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = NtQueryValueKey(KeyHandle,
|
||||||
|
&ValueName,
|
||||||
|
KeyValuePartialInformation,
|
||||||
|
KeyInfo,
|
||||||
|
KeyInfoSize,
|
||||||
|
&ReturnedSize);
|
||||||
|
NtClose(KeyHandle);
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT("NtQueryValueKey() failed (Status %lx)\n", Status);
|
||||||
|
RtlFreeHeap(RtlGetProcessHeap(), 0, KeyInfo);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dwFlags & LCID_SUPPORTED)
|
||||||
|
{
|
||||||
|
DPRINT("Locale is supported\n");
|
||||||
|
RtlFreeHeap(RtlGetProcessHeap(), 0, KeyInfo);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueData = (PWSTR)&KeyInfo->Data[0];
|
||||||
|
if ((dwFlags & LCID_INSTALLED) &&
|
||||||
|
(KeyInfo->Type == REG_SZ) &&
|
||||||
|
(KeyInfo->DataLength == 2 * sizeof(WCHAR)) &&
|
||||||
|
(ValueData[0] == L'1'))
|
||||||
|
{
|
||||||
|
DPRINT("Locale is supported and installed\n");
|
||||||
|
RtlFreeHeap(RtlGetProcessHeap(), 0, KeyInfo);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
RtlFreeHeap(RtlGetProcessHeap(), 0, KeyInfo);
|
||||||
|
|
||||||
|
DPRINT("IsValidLocale() called\n");
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: stubs.c,v 1.94 2004/10/20 03:46:27 jimtabor Exp $
|
/* $Id: stubs.c,v 1.95 2004/12/04 13:59:41 ekohl Exp $
|
||||||
*
|
*
|
||||||
* KERNEL32.DLL stubs (STUB functions)
|
* KERNEL32.DLL stubs (STUB functions)
|
||||||
* Remove from this file, if you implement them.
|
* Remove from this file, if you implement them.
|
||||||
|
@ -1693,20 +1693,6 @@ VerifyVersionInfoA(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @unimplemented
|
|
||||||
*/
|
|
||||||
BOOL
|
|
||||||
STDCALL
|
|
||||||
EnumSystemLanguageGroupsW(
|
|
||||||
LANGUAGEGROUP_ENUMPROCW lpLanguageGroupEnumProc,
|
|
||||||
DWORD dwFlags,
|
|
||||||
LONG_PTR lParam)
|
|
||||||
{
|
|
||||||
STUB;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue