Search code examples
c#.netcompact-framework

Change UI culture programmatically in WinCE 5 / .NET CF 2


In a standard .NET framework application (not CF), I can change the user UI culture with:

System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("es-AR");
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;

but the .NET CF 2 doesn't support CurrentUICulture for CurrentThread.

So far, I found here that maybe the UI culture can be changed by setting

[HKEY_LOCAL_MACHINE\nls\overrides]\LCID
[HKEY_CURRENT_USER\MUI]\CurLang

but it requires rebooting the device after the change. Is there any other way to do it?

TIA, Pablo


Solution

  • Yes, there is. Instead of hacking the registry, use the documented SetUserDefaultUILanguage() API function. From the remarks section of that API:

    The new LANGID will not take effect until the device is reset.

    Can't get around that. Shouldn't be a problem, users don't change their native language frequently.