Click here to Skip to main content
16,004,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey guys,

As you probably know you can change favorite language in your browser.
In Internet Explorer: Tools -> Internet Options -> Languages
This settings saves data in
"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\International\AcceptLanguage" in registry.

If you change key value to "en-US" then "Languages" dialog in IE will contains English language, in case if value equals to "ru-RU" the dialog shows Russian.

For example your current language is "en-US" in Internet Explorer and you have following page opened in Internet Explorer as well:

    <table cellpadding="0" cellspacing="0" class="table-main">
    <tr>
    <td align="right">Culture name:</td>
    <td><% Response.Write(System.Globalization.CultureInfo.CurrentCulture.DisplayName.ToString() + 
               "<br />LCID: " + System.Globalization.CultureInfo.CurrentCulture.LCID.ToString() +
               "<br />Name: " + System.Globalization.CultureInfo.CurrentCulture.Name); %></td>
    </tr>
</table>


The page shows you the following info:
Culture name: English (United States)
LCID: 1033
Name: en-US 


You change the registry like this:
const String LANG_KEY_NAME = @"Software\Microsoft\Internet Explorer\International";
const String AcceptLanguageKey = @"AcceptLanguage";

RegistryKey languageKey = Registry.CurrentUser.OpenSubKey(LANG_KEY_NAME, RegistryKeyPermissionCheck.ReadWriteSubTree);

languageKey.SetValue(AcceptLanguageKey, "ru-RU");


You update the opened page but result is still
Culture name: English (United States)
LCID: 1033
Name: en-US


but should be:
Russian (Russia)
LCID: 1049
Name: ru-RU


if you open the Language dialog just press "OK" and update page or open this page in new window then the page shows correct info.

I tried this [^] solution. But sending "WM_SETTINGCHANGE" window message doesn't help:
C#
        [Flags]
        public enum SendMessageTimeoutFlags : uint
        {
            SMTO_NORMAL = 0x0,
            SMTO_BLOCK = 0x1,
            SMTO_ABORTIFHUNG = 0x2,
            SMTO_NOTIMEOUTIFNOTHUNG = 0x8,
            SMTO_ERRORONEXIT = 0x0020
        }

        [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        public static extern IntPtr SendMessageTimeout(
            IntPtr windowHandle,
            uint Msg,
            IntPtr wParam,
            IntPtr lParam,
            SendMessageTimeoutFlags flags,
            uint timeout,
            out IntPtr result);

private void ChangeLanguage(){
                IntPtr hwnd;
                IntPtr pResult;
                const uint WM_SETTINGCHANGE = 0x1A;
                Process[] processes = Process.GetProcessesByName("iexplore");

                for (int i = 0; i < processes.Length; i++)
                {
                    hwnd = processes[i].Handle;
                    SendMessageTimeout(hwnd, WM_SETTINGCHANGE, IntPtr.Zero, IntPtr.Zero, SendMessageTimeoutFlags.SMTO_BLOCK, 5000, out pResult);
                }
}


Could you please help me with this? restarting IE is not an option for me.

Thanks.
Posted

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900