views:

275

answers:

2

Hi,

I noticed that when a process starts for the first time, it statically reads some system parameter info only once and keeps it until terminated

which means,

that if there is some modification to the system parameters already read by the process, they wouldn'y reflect until the process is restarted.

e.g. Launch Notepad and type ';' key on the keyboard. Now change the input language from the langauge toolbar to Spanish. Now again hit the key ';'. Though the Input langauge has been changed to Spanish, the keys are still English (as seen by pressing ';' key).

Ideally on pressing ';' afer the input language is changed to Spanish, we should have noticed 'ñ'.

When we restart Notepad, we notice that ';' results in 'ñ' which means that the Notepad process needed to be restarted to take effect.

Is there some way where the process is not needed to be restarted to reflect the change in the Input method?

Thanks

+1  A: 

If a process cares to, it can listen for notifications of changes to various system-wide settings. The wm_SettingChange message comes to mind.

It's a fool's errand to try to make some other process honor setting changes if it hasn't been written to do so. If a program isn't already listening for change notifications and acting upon them, you can't make it act differently.

Notepad probably isn't a good example; it's a pretty simple program, so it doesn't necessarily cover all the details that a good Windows program should.

The "answer" you gave, to refine your question, talks about changing the system's default input language with SystemParametersInfo. When you call that function, it will broadcast the wm_SettingChange message. To be notified of the change, other programs need to listen for that message; do that the same way you listen for any other window messages in your programming environment.

When you receive that message, the wParam parameter will be either spi_GetDefaultInputLang or spi_SetDefaultInputLang; I don't know which. That's you cue to call SystemParametersInfo to find out the new value of the setting. Based on what I've just read in "Languages, Locales, and Keyboard Layouts", you should call ActivateKeyboardLayout using the HKL value you get from SystemParametersInfo.

The process that changes the default input language cannot force other processes to use it. Until they choose for themselves to change their input languages, they will continue using whatever was the language when they started running. That's the distinction between the default setting and the current setting.

Rob Kennedy
What Rob said. You can't make a program that was not designed to update when setting change start updating when settings change. That is a design choice the authors of Notepad decided not to code for.
jmucchiello
A: 

Thanks for your reply, Rob. If it's fine for me to go more precise on my question, here's my scenario:

I have two processes running. Then from process 1, I call SystemParametersInfo winapi as follows:

isFine = SystemParametersInfo(SPI_SETDEFAULTINPUTLANG, 0, &spanishLanguageCode, SPIF_SENDCHANGE);

This api would alter the Input Method of the locale to Spanish (To support Spanish hardware keyboard plugged into the system)

Process 2 (which was Notepad in my last example but can be any other program coded by me where I handle the command change message) was initialized with Input Method of locale as English Now, actually the system vide Input Method is Spanish but Process 2 still takes the inputs from hardware keyboard as English as explained in the example below.

I was wondering if there is some way to update the Input Method Info in the current process and how to do that? How can I see the info in the running process? Is there some tool on the Sysinternals website to view this process information?

Thanks

Please edit your question to contain this new information. The "answer" section is for answers, and you have not answered your own question. If you can't remember how you logged in last time, you might try the "contact us" link at the bottom of the page to get help logging in under your original account.
Rob Kennedy