views:

384

answers:

5

Is there a way to set the Internet Explorer locale (accepted languages) programmatically. I have a small application which is embedding Internet Explorer and I would like to give the use the possibility to change the locale when clicking a simple button.

Is there a way besides tweaking registry and calling

SendMessageTimeout(HWND_BROADCAST,WM_SETTINGCHANGE , 0, ...);

A: 

Unfortunately not -- IE pulls its settings directly from the registry.

David Pfeffer
A: 

Just a suggestion but it might make more sense to use a rendering engine better suited to embedded such as webkit.

ternaryOperator
Currently the app is embedding gecko and Internet Explorer, webkit is planned ...
tmax_dev
A: 

Do I need to broadcast the message to all TopLevel-Windows using HWND_BROADCAST or is there a faster way to tell my app about the changes.

tmax_dev
If you do change global settings (which you shouldn't, at least for this) then yes, broadcasting the WM_SETTINGCHANGE is part of your responsibility.
MSalters
+2  A: 

Yes - when you embed IE (Actually MSHTML), you can change the registry entries used for just that instance. This is done by a callback to your IDocHostUIHandler::GetOptionKeyPath Method

MSalters
This is the right fix. Anything else is a hack that will interfere with the proper operation of other applications.
EricLaw -MSFT-
Thanks, I'll give it a try.
tmax_dev
A: 

I use the IDocHostUIHandler2::GetOverrideKeyPath Method now implementing IDocHostUIHandler2 Interface. The problem is, that my App first reads my setting from SOFTWARE/MyCompany/MyApp/International

and after that reads again from SOFTWARE/Microsoft/Internet Explorer/International

my code :

HRESULT MyApp::GetOverrideKeyPath( LPOLESTR pchKey, DWORD dw) { HRESULT hr; WCHAR szKey = L"Software\MyCompany\MyApp";

//  cbLength is the length of szKey in bytes.
size_t cbLength;
hr = StringCbLengthW(szKey, 1280, &cbLength);

if (pchKey)
{
    *pchKey = (LPOLESTR)CoTaskMemAlloc(cbLength + sizeof(WCHAR));
    if (*pchKey)
        hr = StringCbCopyW(*pchKey, cbLength + sizeof(WCHAR), szKey);
}
else
    hr = E_INVALIDARG;

return hr;

}

tmax_dev