[KERNEL32_VISTA] Implement LCIDToLocaleName

This commit is contained in:
Timo Kreuzer 2025-05-08 16:06:29 +03:00
parent 7c1b7ee87d
commit 48ec990a49
4 changed files with 63 additions and 0 deletions

View file

@ -12,6 +12,7 @@ list(APPEND SOURCE
GetTickCount64.c
GetUserDefaultLocaleName.c
InitOnce.c
LCIDToLocaleName.c
LocaleNameToLCID.c
sync.c
vista.c)

View file

@ -0,0 +1,59 @@
/*
* PROJECT: ReactOS Win32 Base API
* LICENSE: MIT (https://spdx.org/licenses/MIT)
* PURPOSE: Implementation of LCIDToLocaleName
* COPYRIGHT: Copyright 2025 Timo Kreuzer <timo.kreuzer@reactos.org>
*/
#include "k32_vista.h"
#include <ndk/rtlfuncs.h>
int
WINAPI
LCIDToLocaleName(
_In_ LCID Locale,
_Out_writes_opt_(cchName) LPWSTR lpName,
_In_ int cchName,
_In_ DWORD dwFlags)
{
WCHAR Buffer[LOCALE_NAME_MAX_LENGTH];
UNICODE_STRING LocaleNameString;
DWORD RtlFlags = 0;
NTSTATUS Status;
if (cchName < 0)
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
if (dwFlags & LOCALE_ALLOW_NEUTRAL_NAMES)
{
RtlFlags |= RTL_LOCALE_ALLOW_NEUTRAL_NAMES;
}
if (lpName != NULL)
{
cchName = min(cchName, LOCALE_NAME_MAX_LENGTH);
LocaleNameString.Buffer = lpName;
LocaleNameString.Length = 0;
LocaleNameString.MaximumLength = (USHORT)(cchName * sizeof(WCHAR));
}
else
{
LocaleNameString.Buffer = Buffer;
LocaleNameString.Length = 0;
LocaleNameString.MaximumLength = sizeof(Buffer);
}
/* Call the RTL function */
Status = RtlLcidToLocaleName(Locale, &LocaleNameString, RtlFlags, FALSE);
if (!NT_SUCCESS(Status))
{
SetLastError(RtlNtStatusToDosError(Status));
return 0;
}
/* Return the length including the terminating null */
return (LocaleNameString.Length / sizeof(WCHAR)) + 1;
}

View file

@ -44,6 +44,7 @@
@ stdcall GetUILanguageInfo(long wstr wstr ptr ptr)
@ stdcall GetUserDefaultLocaleName(wstr long)
@ stdcall GetUserPreferredUILanguages(long ptr wstr ptr)
@ stdcall LCIDToLocaleName(long wstr long long)
@ stdcall LocaleNameToLCID(wstr long)
@ stdcall OpenFileById(ptr ptr long long ptr long)
@ stdcall QueryFullProcessImageNameA(ptr long str ptr)

View file

@ -1439,6 +1439,7 @@ LCID WINAPI LocaleNameToLCID( LPCWSTR name, DWORD flags )
#endif
#if 0 // See kernel32_vista
/***********************************************************************
* LCIDToLocaleName (KERNEL32.@)
*/
@ -1449,6 +1450,7 @@ INT WINAPI LCIDToLocaleName( LCID lcid, LPWSTR name, INT count, DWORD flags )
return GetLocaleInfoW( lcid, LOCALE_SNAME | LOCALE_NOUSEROVERRIDE, name, count );
}
#endif
#endif
/******************************************************************************