了解操作系统何时进入屏幕保护程序 [英] To know when OS goes into screen saver

查看:89
本文介绍了了解操作系统何时进入屏幕保护程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以让VB知道操作系统

何时进入屏幕保存模式?我有连续的民意调查我希望在屏幕保存模式下暂停。
同样地,当屏幕保护程序关闭时,我们会再次唤醒。


任何对此的帮助将不胜感激。


Rob

Is there a way that VB can know when the operating system
goes into screen save mode? I have continuous polling I
wish to pause while in screen save mode. And likewise to
wake back up when the screen saver is turned back off.

Any help on this will be greatly appreciated.

Rob

推荐答案

Rob写道:
VB是否有办法知道何时运行系统进入屏幕保存模式?我有连续的轮询我希望在屏幕保存模式下暂停。同样在屏幕保护程序关闭时唤醒。

任何对此的帮助将不胜感激。

Rob
Is there a way that VB can know when the operating system
goes into screen save mode? I have continuous polling I
wish to pause while in screen save mode. And likewise to
wake back up when the screen saver is turned back off.

Any help on this will be greatly appreciated.

Rob




你可以使用SystemParametersInfo和SPI_GETSCREENSAVERRUNNING标志

来查看屏幕保护程序是否正在运行...换句话说,你可以

有一个每隔一秒左右触发的计时器并调用此函数。如果

它正在运行,则让你的工作线程进入休眠状态。如果不是,请将其唤醒......


HTH,

Tom Shelton



You can use SystemParametersInfo with the SPI_GETSCREENSAVERRUNNING flag
to find out if the screen saver is running... In other words, you could
have a timer that fires every second or so and calls this function. If
it''s running put your worker thread to sleep. If it''s not, wake it up...

HTH,
Tom Shelton


嗨Rob,


某些Windows事件可以等待,例如系统关闭,显示

属性更改等(参见SystemEvents类)。不幸的是,当屏幕保护程序启动时,没有提到任何Windows事件。


以下是VB(经典)项目,它检测是否

工作站是否已锁定。它包含一些非常简单的代码来检测屏幕保护程序是否正在运行,但你必须继续检查。

http://www.mvps.org/st-software/Code...orkstation.zip


问候,

Fergus
Hi Rob,

Certain Windows events can be waited on, eg system shutdown, display
properties changes, etc.(see the SystemEvents class). Unfortunately there''s no
mention of any Windows event occurring when the screen saver starts.

The following is a VB (classic) project which detects whether a
workstation is locked or not. It include some very straightforward code to
detect whether the screen saver is running, but you''ll have to keep checking.

http://www.mvps.org/st-software/Code...orkstation.zip

Regards,
Fergus


" Rob" < RO ** @ stl.NO.hamptontilley.SPAM.com> schrieb
"Rob" <ro**@stl.NO.hamptontilley.SPAM.com> schrieb
有什么方法可以让VB知道操作系统什么时候进入屏幕保存模式?我有连续的轮询我希望在屏幕保存模式下暂停。同样,当屏幕保护程序关闭时唤醒。

任何对此的帮助将不胜感激。
Is there a way that VB can know when the operating system
goes into screen save mode? I have continuous polling I
wish to pause while in screen save mode. And likewise to
wake back up when the screen saver is turned back off.

Any help on this will be greatly appreciated.




受保护的覆盖子WndProc(_

ByRef m As System.Windows.Forms.Message)


Const WM_SYSCOMMAND As Integer =& H112
Const SC_SCREENSAVE As Integer =& HF140


MyBase.WndProc(m)


如果m.Msg = WM_SYSCOMMAND _

AndAlso m.WParam.ToInt32 = SC_SCREENSAVE然后


Debug.WriteLine(屏幕保护程序激活)

结束如果< br $>
End Sub

-

Armin



Protected Overrides Sub WndProc( _
ByRef m As System.Windows.Forms.Message)

Const WM_SYSCOMMAND As Integer = &H112
Const SC_SCREENSAVE As Integer = &HF140

MyBase.WndProc(m)

If m.Msg = WM_SYSCOMMAND _
AndAlso m.WParam.ToInt32 = SC_SCREENSAVE Then

Debug.WriteLine("Screensaver activated")
End If
End Sub
--
Armin


这篇关于了解操作系统何时进入屏幕保护程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆