更改正在运行的进程的设置

时间:2022-11-05 22:45:41

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).

例如启动记事本并输入';'键盘上的键。现在将输入语言从langauge工具栏更改为西班牙语。现在再次点击键';'。虽然输入语言已更改为西班牙语,但键仍为英语(按';'键可以看到)。

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?

是否有某种方法可以不重新启动进程以反映Input方法的更改?

Thanks

1 个解决方案

#1


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

如果进程关心,它可以侦听各种系统范围设置的更改通知。想到了wm_SettingChange消息。

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.

记事本可能不是一个好例子;这是一个非常简单的程序,因此它不一定涵盖一个好的Windows程序应该具备的所有细节。

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.

您提供的“答案”,以优化您的问题,讨论使用SystemParametersInfo更改系统的默认输入语言。当您调用该函数时,它将广播wm_SettingChange消息。要收到更改通知,其他程序需要监听该消息;这样做就像在编程环境中监听任何其他窗口消息一样。

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.

当您收到该消息时,wParam参数将是spi_GetDefaultInputLang或spi_SetDefaultInputLang;我不知道哪个。你提示调用SystemParametersInfo来找出设置的新值。基于我刚刚在“语言,语言环境和键盘布局”中阅读的内容,您应该使用从SystemParametersInfo获得的HKL值来调用ActivateKeyboardLayout。

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.

更改默认输入语言的过程无法强制其他进程使用它。在他们选择自己更改输入语言之前,他们会在开始运行时继续使用任何语言。这是默认设置和当前设置之间的区别。

#1


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

如果进程关心,它可以侦听各种系统范围设置的更改通知。想到了wm_SettingChange消息。

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.

记事本可能不是一个好例子;这是一个非常简单的程序,因此它不一定涵盖一个好的Windows程序应该具备的所有细节。

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.

您提供的“答案”,以优化您的问题,讨论使用SystemParametersInfo更改系统的默认输入语言。当您调用该函数时,它将广播wm_SettingChange消息。要收到更改通知,其他程序需要监听该消息;这样做就像在编程环境中监听任何其他窗口消息一样。

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.

当您收到该消息时,wParam参数将是spi_GetDefaultInputLang或spi_SetDefaultInputLang;我不知道哪个。你提示调用SystemParametersInfo来找出设置的新值。基于我刚刚在“语言,语言环境和键盘布局”中阅读的内容,您应该使用从SystemParametersInfo获得的HKL值来调用ActivateKeyboardLayout。

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.

更改默认输入语言的过程无法强制其他进程使用它。在他们选择自己更改输入语言之前,他们会在开始运行时继续使用任何语言。这是默认设置和当前设置之间的区别。