当前位置:网站首页>Accessing user interface settings using systemparametersinfo

Accessing user interface settings using systemparametersinfo

2022-06-24 07:22:00 Topomeyer - long development road

SystemParametersInfo This function is very useful , It can be used to access the user interface settings in the operating system in the form of code , And it is the only function that can be used to modify settings . In today's article , I won't list all the setup parameters supported by this function , If necessary , Please go out and turn left to read the document , That's where you need to go . I just want to say something worth noting :

> SPI_GETICONTITLELOGFONT
This parameter can be used to obtain the font information of the icon text . Corresponding ,SPI_SETICONTITLELOGFONT Can be used to modify .

> SPI_GETNONCLIENTMETRICS
This parameter can be used to get the window title , menu , Font information of status bar and message prompt box , Corresponding ,SPI_SETNONCLIENTMETRICS Can be used to modify .

Here are some corresponding parameters on the control panel :

> SPI_SETKEYBOARDDELAY and SPI_SETKEYBOARDSPEED It can be used to set the keyboard to automatically repeat relevant parameters .
> SPI_SETDOUBLECLICKTIME Can be used to set the mouse double-click speed .
> SPI_SETMENUFADE Can be used to enable or disable menu fade animation .
> There's another one SPI_SETxxxANIMATION Series parameters , It can be used to control which screen components can be animated .

Please note that , When using SPI_SET* When parameters are , You also need to indicate that the value to be set is temporary ( The settings become invalid after logging off ) It's permanent .SPIF_UPDATEINIFILE This flag specifies that the settings will be saved to the user profile . If this flag is turned off , The settings will not be saved , And it will be invalid when the user logs off . in addition , You also need to add SPIF_SENDCHANGE sign , In this way, programs that want to receive the setting change event can receive this notification and take corresponding actions .

Because the change of system settings can be temporary , It can also be permanent , This creates a potential problem : Programs that directly access the registry to read or write system settings may not work as expected . If the current setting is temporary , These settings will not be saved to the registry .SystemParametersInfo This function will get the current actual setting value , It also contains temporary settings that just reside in memory .

for instance , If you want to check whether the current menu has animation enabled , If the user has temporarily disabled the animation , If you judge by reading the registry , The value you read may be different from the current value . in addition , Those settings written to the registry change , It will only take effect the next time the user logs in , Because the new settings will be reloaded at this time .

If you want the settings to take effect immediately , have access to SystemParametersInfo This function . What still confuses me is , Why do people use undocumented registry entries to change these settings , Instead of using the system API To achieve . Especially when API Can work normally , When undocumented registry entries are less reliable .

I remember , There was an application , It is not provided by the system API, Instead, access undocumented registry keys directly ( I think I want to get the font of icon text. I remember ). But the surprise is , It reads the registry in Windows 2000 Changes have taken place in ( The program is oriented to Windows 95 platform ). If the developer uses a standardized API Come true , The program can run in the new version of the system without any changes .

let me put it another way , Developers try to bypass the most appropriate technical route , I used a method that I thought would be successful . But in the end, he lifted a stone and hit himself in the foot .

summary

If you want your program to survive longer , Please try to use standardized , Documented API.
TopomelBox Do not pursue strange sexual skills , But step by step according to the document , Sometimes I even see API Whether to mark as Obsolete.

Last

Raymond Chen Of 《The Old New Thing》 It's one of my favorite blogs , There's a lot about Windows Little knowledge , For the vast Windows For platform developers , It's really helpful .
This article is from :《Using SystemParametersInfo to access user interface settings》

原网站

版权声明
本文为[Topomeyer - long development road]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206240143544976.html