|
UCMESSc.exe:直接雙擊該程序?qū)㈥P(guān)閉顯示器,在CMD窗口中執(zhí)行該程序時可以加參數(shù)cm或ss。 UCMESSc.exe cm 關(guān)閉屏幕; UCMESSc.exe ss 進入屏幕保護程序; 可以將CloseMonitor.cmd,EnterScreenSaver.cmd的快捷方式放到桌面,雙擊CloseMonitor.cmd將關(guān)閉顯示器,雙擊EnterScreenSaver.cmd 將進入屏幕保護程序。
UCMESS.exe:直接雙擊該程序會跳出一窗口,點擊"Close Monitor"按鈕將關(guān)閉顯示器,點擊"Enter Screen Saver"按鈕將進入屏幕保護程序。
文件MD5信息: File name MD5 value UCMESSc.exe 89c43352b6d5db291f810387dcaa5e55 UCMESS.exe 94f65e0a550d76971d1614bdd93cfffe CloseMonitor.cmd 6d7c807cb6291456d45dee7fa4390504 EnterScreenSaver.cmd 37343733f2ed02f05e2a69f201f19394
網(wǎng)上有一個名為CloseMonitor.exe的程序,我在2006年就用到它了,不過一直沒關(guān)心它的實現(xiàn)原理是什么,最近又用到這個程序的時候,特地將其的 實現(xiàn)原理研究了一下,原來如此簡單。 CloseMonitor.exe用的是SendMessage(HWND_BROADCAST,WM_SYSCOMMAND,SC_MONITORPOWER,2),這種寫法可能導(dǎo)致程序沒法結(jié)束并一直留在進程隊列中, 因
為The SendMessage function sends the specified message to a window or
windows. It calls the window procedure for the specified window and does
not return until the window procedure has processed the message.
我用的方法是PostMessage(HWND_BROADCAST,WM_SYSCOMMAND,SC_MONITORPOWER,1);PostMessage(HWND_BROADCAST,WM_SYSCOMMAND,SC_MONITORPOWER,2) 首
先我用了PostMessage的方法,The PostMessage function places (posts) a message in
the message queue associated with the thread that created the specified
window and returns without waiting for the thread to process the
message. 該方法被調(diào)用之后會馬上返回,從而不會 造成程序一直無法結(jié)束。另外我兩次PostMessage最后的一個參數(shù)分別為1和2(1:the display is going to low power; 2:the display is being shut off) 這樣基本可以保證大多數(shù)的屏幕是可以被關(guān)掉的。 另外我添加了一個新的功能:PostMessage(HWND_BROADCAST,WM_SYSCOMMAND, SC_SCREENSAVE, 0);即進入屏幕保護程序。 在UCMESS.exe中我用GetSafeHwnd()取代HWND_BROADCAST,這樣可以避免有時關(guān)屏幕會出現(xiàn)開關(guān)好幾次的問題。
針對這個程序的問題請訪問我的博客lawrencedon.blog.hexun.com,給我留言,或回復(fù)我的文章:Utility to Close Monitor or Enter Screen Saver v1.0.0.1
|