当前位置:网站首页>Why pass SPIF_ Sendchange flag systemparametersinfo will hang?
Why pass SPIF_ Sendchange flag systemparametersinfo will hang?
2022-06-27 01:46:00 【Topomeyer - long development road】
If you deliver SPIF_SENDCHANGE Mark for SystemParametersInfo function , Then it will send to the system in the form of broadcast WM_SETTINGCHANGE news , And send the message to wParam The parameter is set to the flag you pass to the function . for example , If you call :
SystemParametersInfo(SPI_SETDOUBLECLICKTIME,500, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
The system will broadcast the following messages :
SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETDOUBLECLICKTIME, 0);
If a window in the system does not respond to this summer limit , The broadcast will be suspended until the window responds to the message or the window is destroyed .
If you want to avoid unresponsive behavior in other windows , There are some ways , But it can also have an unexpected impact on your program .
You can execute in a background thread SystemParametersInfo call , Then even if it is suspended , Only the background thread is suspended , The main interface still works normally .
With this message , The background thread can notify the main thread when the broadcast is finally completed , At this point your program now knows that all windows have received their notifications and are using the new settings .
You can still not have SPIF_SENDCHANGE In case of a sign SystemParametersInfo call , Then change by manually broadcasting , as follows :
DWORD dwResult;
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE,SPI_SETDOUBLECLICKTIME, 0,SMTO_ABORTIFHUNG | SMTO_NOTIMEOUTIFNOTHUNG, 5000, &dwResult);
This does mean that unresponsive windows will not be notified that system parameters have changed . If you think your settings have changed very little , So that the lack of notification procedures is no big deal , This is acceptable . let me put it another way , When the unresponsive program finally wakes up , It doesn't know that the settings have changed , Because it missed the notice .
You can combine the above two methods : Use a background thread and send a timeout message .
Perhaps the best technique is to use SendNotifyMessage function . As mentioned earlier ,SendNotifyMessage Function and SendMessage similar , It just doesn't wait for a response . This will get your program back to work , It won't mess up the procedures that are temporarily unresponsive when you decide to broadcast a notification .
SendNotifyMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETDOUBLECLICKTIME, 0);
The disadvantage is that , You don't know when all windows finally receive and process notifications . All you know is , One day , They will eventually discover . Usually you don't care about this aspect of broadcasting , So this lack of information is not an obstacle .
summary
Independent , Independent , Independent .
Where possible , Try to make your program and other components less dependent : Do not call their functions , Do not import their libraries , Do not reference their header files . such , In the world of programs , You are free .
Be careful , The premise of the above practice is : Where possible .
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 :《Why does SystemParametersInfo hang when I pass the SPIF_SENDCHANGE flag?》

边栏推荐
- Memcached foundation 9
- svg拖拽装扮Kitty猫
- Memcached Foundation 12
- Config in UVM_ How to use the DB mechanism
- Parameter transfer method between two pages
- NOKOV动作捕捉系统使多场协同无人机自主建造成为可能
- numpy 数组运算机制浅探
- Analysis of ideal L9 product power: the price is 459800 yuan, the four cylinder engine is adopted, and the endurance is 1315km
- Pointer compression for JVM
- idea 插件开发一些异常处理
猜你喜欢

按键控制LED状态翻转

每日刷题记录 (五)

1.44 inch TFT-LCD display screen mold taking tutorial

Learn the most basic operation of discodiffusion

Summary of config mechanism and methods in UVM (2)
![[graduation season] role conversion](/img/4e/aa763455da974d9576a31568fc6625.jpg)
[graduation season] role conversion

做了两天的唯美蝴蝶动画

博日科技招股书失效,中金公司已停止对其辅导,放弃港交所上市?

在连接数据库的时候遇到了点问题,请问怎么解决呀?

Simply learn the entry-level concepts of googlecolab
随机推荐
UVM in UVM_ config_ Use of DB in sequence
NOKOV动作捕捉系统使多场协同无人机自主建造成为可能
Config in UVM_ How to use the DB mechanism
ThreadLocal详解
两个页面之间传参方法
我靠副业一个月挣了3W块:你看不起的行业,真的很挣钱!
Due to the invalidation of the prospectus of bori technology, CICC has stopped providing guidance to it and abandoned the listing on the Hong Kong stock exchange?
【系统分析师之路】第六章 复盘需求工程(案例论文)
Oracle/PLSQL: From_Tz function
简单学习GoogleColab的入门级概念
二叉樹oj題目
SystemVerilog simulation speed increase
UVM中config_db机制的使用方法
为什么传递SPIF_SENDCHANGE标志SystemParametersInfo会挂起?
Oracle/PLSQL: Rtrim Function
XSS笔记(下)
memcached基礎12
I encountered some problems when connecting to the database. How can I solve them?
福元医药上市在即:募资净额将达到16亿元,胡柏藩为实际控制人
Oracle/PLSQL: Length Function