UCMESS:Utility to Close Monitor or Enter Screen Saver

Utility to Close Monitor or Enter Screen Saver v1.0.0.1
Release Date:2009 06 19
Program Name:UCMESS
Author:Lawrence Don
E-mail:LawrenceDon@163.com
Support Web: lawrencedon.blog.hexun.com
下载地址:http://sites.google.com/site/downloadcenterforldsstudio/Home/UCMESS.rar?attredirects=0

支持的操作系统:Win2000,WinXP,Vista,Win7

请确定你在系统中启用了屏幕保护功能,否则该程序的进入屏幕保护功能将无效。

UCMESSc.exe:直接双击该程序将关闭显示器,在CMD窗口中执行该程序时可以加参数cm或ss。
            UCMESSc.exe cm 关闭屏幕;
            UCMESSc.exe ss 进入屏幕保护程序;
            可以将CloseMonitor.cmd,EnterScreenSaver.cmd的快捷方式放到桌面,双击CloseMonitor.cmd将关闭显示器,双击EnterScreenSaver.cmd
            将进入屏幕保护程序。

UCMESS.exe:直接双击该程序会跳出一窗口,点击"Close Monitor"按钮将关闭显示器,点击"Enter Screen Saver"按钮将进入屏幕保护程序。

文件MD5信息:
File name              MD5 value
UCMESSc.exe            89c43352b6d5db291f810387dcaa5e55
UCMESS.exe             94f65e0a550d76971d1614bdd93cfffe
CloseMonitor.cmd       6d7c807cb6291456d45dee7fa4390504
EnterScreenSaver.cmd   37343733f2ed02f05e2a69f201f19394

网上有一个名为CloseMonitor.exe的程序,我在2006年就用到它了,不过一直没关心它的实现原理是什么,最近又用到这个程序的时候,特地将其的
实现原理研究了一下,原来如此简单。
CloseMonitor.exe用的是SendMessage(HWND_BROADCAST,WM_SYSCOMMAND,SC_MONITORPOWER,2),这种写法可能导致程序没法结束并一直留在进程队列中,
因为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. 该方法被调用之后会马上返回,从而不会
造成程序一直无法结束。另外我两次PostMessage最后的一个参数分别为1和2(1:the display is going to low power; 2:the display is being shut off)
这样基本可以保证大多数的屏幕是可以被关掉的。
另外我添加了一个新的功能:PostMessage(HWND_BROADCAST,WM_SYSCOMMAND, SC_SCREENSAVE, 0);即进入屏幕保护程序。
在UCMESS.exe中我用GetSafeHwnd()取代HWND_BROADCAST,这样可以避免有时关屏幕会出现开关好几次的问题。

针对这个程序的问题请访问我的博客lawrencedon.blog.hexun.com,给我留言,或回复我的文章:Utility to Close Monitor or Enter Screen Saver v1.0.0.1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值