From: Kid on
Hi

How can I detect Windows system language or codepage by Win32 or MFC ?

Is there some registry key to query ?

Thank you .
From: David Ching on
"Kid" <Kid(a)discussions.microsoft.com> wrote in message
news:5E835E05-D8ED-4249-A587-A7EC9E061F02(a)microsoft.com...
> How can I detect Windows system language or codepage by Win32 or MFC ?
>

e.g.
WORD wDefLang = LANGIDFROMLCID(GetUserDefaultLCID());
LANGID wDefLang = GetSystemDefaultLangID(); // or
GetUserDefaultLangID();

There is some debate about which API is appropriate for your usage.

-- David


From: Mihai N. on

> How can I detect Windows system language or codepage by Win32 or MFC ?

It depends what you mean by "system language"

For each you have the option to get them in a numeric form
(LCID, used all the way to XP) or string (starting with Vista)
You can also get a language ID (LANGID), but it might not be enough
for all operations (a locale is usualy a better choice).

The language in which the UI was localized at install time?
GetSystemDefaultUILanguage -> LANGID

The language in which the UI is displayed right now?
(might be different than the system UI language if you have a MUI or LIP)
GetUserDefaultUILanguage -> LANGID

The system locale (that determines the ANSI and OEM code pages)?
GetSystemDefaultLocaleName -> string
GetSystemDefaultLCID -> LCID
GetSystemDefaultLangID -> LANGID

The locale used for locale-sensitive operations
(number/currency/date/time formatting, sorting, case conversion)?
GetUserDefaultLocaleName -> string
GetUserDefaultLCID -> LCID
GetUserDefaultLangID -> LANGID


For system code page there are two of them:
- the ANSI code page => GetACP
- the OEM code page, used (by default) by console apps => GetOEMCP


--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email

From: Joseph M. Newcomer on
Download my Locale Explorer. It will even generate the code for you.
joe

On Thu, 17 Jun 2010 20:06:51 -0700, Kid <Kid(a)discussions.microsoft.com> wrote:

>Hi
>
>How can I detect Windows system language or codepage by Win32 or MFC ?
>
>Is there some registry key to query ?
>
>Thank you .
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Tom Serface on
I use pretty simple code like:

LCID lcid = ::GetThreadLocale() & 0x00ff;
lcid |= lcid == 0x0004?0x0800:0x0400; // Chinese starts with 08, but all
others 04

Then I build a filename for the language DLL using

CString csResourceDLL = GetResourceFilename(lcid, _T("MYAPP%1.dll"));

//
// Creates a resource file name (for a DLL) given the locale id and a format
string.
//
CString GetResourceFilename(UINT nLID, LPCTSTR cFormat)
{
CString csHex, cs;
csHex.Format(_T("%04x"), nLID);
cs.FormatMessage(cFormat,csHex);
return cs;
}

But we don't use the sub language since we don't support anything except a
few top level languages.

Tom

"Kid" <Kid(a)discussions.microsoft.com> wrote in message
news:5E835E05-D8ED-4249-A587-A7EC9E061F02(a)microsoft.com...
> Hi
>
> How can I detect Windows system language or codepage by Win32 or MFC ?
>
> Is there some registry key to query ?
>
> Thank you .