We know that we can use English version of Windows and at the same time to display non-unicode texts such as Chinese and Japanese etc. The procedures are as follows:
Control Panel > Region > Administrative Tab, and then “Change system locale” button.
But how do this using C#? This post offers my initial attempt to accomplish this task.
The settings for this non-unicode languages are kept in registry:
The value for the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\Language “default” value is the hex code (LCID Hexadecimal) of the system’s non-unicode language, for commonly used LCID code, click here or this link from Microsoft for details.
For instance, “0804” is the hex LCID code for “Chinese – People’s Republic of China”.
To get or change the non-unicode languages for windows OS, we can edit this registry key value using C#, and the code snippet is like this:
Similarly, the code to set a specific language is then straightforward:
But wait, this is not all! If you calling the function:
you will find there is no error, no exception, and using regedit.exe shows the registry key is also changed correctly, but, if you using control panel region settings to have a look, you will find this is NOT updated. The reason is, you have to restart to make this setting take effect!
So, I created another function to restart the computer in code:
Great! Now call the RestartComputer() after calling SetSystemNonUnicodeLanguage(), it worked.