···33 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
44 * PURPOSE: Base set of functions for loading string resources
55 * and message strings, and handle type identification.
66- * COPYRIGHT: Copyright 2017-2018 ReactOS Team
77- * Copyright 2017-2018 Hermes Belusca-Maito
66+ * COPYRIGHT: Copyright 2017-2021 ReactOS Team
77+ * Copyright 2017-2021 Hermes Belusca-Maito
88 */
991010/**
···318318 _SEH2_END;
319319320320 return dwLength;
321321+}
322322+323323+/**
324324+ * @name ConSetThreadUILanguage
325325+ * Sets the current thread's user interface language.
326326+ * Mostly used by console applications for selecting a
327327+ * language identifier that best supports the NT Console.
328328+ * This function dynamically loads and calls kernel32!SetThreadUILanguage()
329329+ * so as to be able to work on older environments where this
330330+ * API is not supported.
331331+ * The FormatMessage() API also bases itself on the thread's
332332+ * current language for its default behaviour (unless an explicit
333333+ * language identifier has been provided).
334334+ *
335335+ * @param[in,opt] LangId
336336+ * (Vista+) A non-zero language identifier that specifies the
337337+ * current thread's user interface language to set.
338338+ * (XP/2003) Set the language identifier to 0 for selecting a
339339+ * language identifier that best supports the NT Console.
340340+ *
341341+ * @return
342342+ * Returns LangId in case of success, or 0 in case of failure.
343343+ * If LangId was set to 0, the function always succeeds and returns
344344+ * the language identifier that best supports the NT Console.
345345+ *
346346+ * @remark
347347+ * This function is thread-safe.
348348+ *
349349+ * @see <a href="https://docs.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-setthreaduilanguage">SetThreadUILanguage() (on MSDN)</a>
350350+ **/
351351+LANGID
352352+ConSetThreadUILanguage(
353353+ IN LANGID LangId OPTIONAL)
354354+{
355355+ /* The function pointer is shared amongst all threads */
356356+ static volatile LANGID (WINAPI *pfnSetThreadUILanguage)(LANGID) = NULL;
357357+358358+ if (!pfnSetThreadUILanguage)
359359+ {
360360+ /* Load the API from kernel32 */
361361+ PVOID pFunc = (PVOID)GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "SetThreadUILanguage");
362362+ if (!pFunc)
363363+ {
364364+ /* Fail since the API is not available */
365365+ return 0;
366366+ }
367367+ /* Set the function pointer in case it hasn't been already set by another thread */
368368+ InterlockedCompareExchangePointer((PVOID*)&pfnSetThreadUILanguage, pFunc, NULL);
369369+ // ASSERT(pfnSetThreadUILanguage);
370370+ }
371371+ return pfnSetThreadUILanguage(LangId);
321372}
322373323374/**
+6-2
sdk/lib/conutils/utils.h
···33 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
44 * PURPOSE: Base set of functions for loading string resources
55 * and message strings, and handle type identification.
66- * COPYRIGHT: Copyright 2017-2018 ReactOS Team
77- * Copyright 2017-2018 Hermes Belusca-Maito
66+ * COPYRIGHT: Copyright 2017-2021 ReactOS Team
77+ * Copyright 2017-2021 Hermes Belusca-Maito
88 */
991010/**
···5555 OUT LPWSTR lpBuffer,
5656 IN DWORD nSize,
5757 IN va_list *Arguments OPTIONAL);
5858+5959+LANGID
6060+ConSetThreadUILanguage(
6161+ IN LANGID LangId OPTIONAL);
58625963BOOL
6064IsTTYHandle(IN HANDLE hHandle);