ReactOS 0.4.16-dev-1602-gd4d52e1
LCIDToLocaleName.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Win32 Base API
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: Implementation of LCIDToLocaleName
5 * COPYRIGHT: Copyright 2025 Timo Kreuzer <timo.kreuzer@reactos.org>
6 */
7
8#include "k32_vista.h"
9#include <ndk/rtlfuncs.h>
10
11int
14 _In_ LCID Locale,
16 _In_ int cchName,
18{
20 UNICODE_STRING LocaleNameString;
21 DWORD RtlFlags = 0;
23
24 if (cchName < 0)
25 {
27 return 0;
28 }
29
31 {
32 RtlFlags |= RTL_LOCALE_ALLOW_NEUTRAL_NAMES;
33 }
34
35 if (lpName != NULL)
36 {
38 LocaleNameString.Buffer = lpName;
39 LocaleNameString.Length = 0;
40 LocaleNameString.MaximumLength = (USHORT)(cchName * sizeof(WCHAR));
41 }
42 else
43 {
44 LocaleNameString.Buffer = Buffer;
45 LocaleNameString.Length = 0;
46 LocaleNameString.MaximumLength = sizeof(Buffer);
47 }
48
49 /* Call the RTL function */
50 Status = RtlLcidToLocaleName(Locale, &LocaleNameString, RtlFlags, FALSE);
51 if (!NT_SUCCESS(Status))
52 {
54 return 0;
55 }
56
57 /* Return the length including the terminating null */
58 return (LocaleNameString.Length / sizeof(WCHAR)) + 1;
59}
int WINAPI LCIDToLocaleName(_In_ LCID Locale, _Out_writes_opt_(cchName) LPWSTR lpName, _In_ int cchName, _In_ DWORD dwFlags)
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
NTSYSAPI NTSTATUS WINAPI RtlLcidToLocaleName(LCID, UNICODE_STRING *, ULONG, BOOLEAN)
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
LPCWSTR LPCWSTR LPCWSTR DWORD dwFlags
Definition: env.c:37
#define min(a, b)
Definition: monoChain.cc:55
#define _Out_writes_opt_(s)
Definition: no_sal2.h:226
#define _In_
Definition: no_sal2.h:158
#define LOCALE_NAME_MAX_LENGTH
unsigned short USHORT
Definition: pedump.c:61
DWORD LCID
Definition: nls.h:13
USHORT MaximumLength
Definition: env_spec_w32.h:370
_In_ LPCSTR lpName
Definition: winbase.h:2498
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
Definition: winbase.h:2476
#define WINAPI
Definition: msvc.h:6
#define LOCALE_ALLOW_NEUTRAL_NAMES
Definition: winnls.h:25
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184