本文介绍了以编程方式关闭屏幕保护程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要以编程方式打开屏幕保护程序,我通过Googling找到了以下代码(C#.NET Framework 3.5)

To turn on screen saver programmatically, I found the following code(C# .NET framework 3.5) by Googling

[DllImport("User32.dll")]
public static extern int SendMessage
(IntPtr hWnd,
uint Msg,
uint wParam,
uint lParam);
public const uint WM_SYSCOMMAND = 0x112;
public const uint SC_SCREENSAVE = 0xF140;
public enum SpecialHandles
{
HWND_DESKTOP = 0x0,
HWND_BROADCAST = 0xFFFF
}
public static void TurnOnScreenSaver()
{
SendMessage(
new IntPtr((int)SpecialHandles.HWND_BROADCAST),
WM_SYSCOMMAND,
SC_SCREENSAVE,
0);
}


此代码可以很好地打开屏幕保护程序.

我需要另一种方法,例如TurnOnScreenSaver(),它可以停止屏幕保护程序.我想先打开屏幕保护程序(已经完成),然后在特定条件下关闭屏幕保护程序,然后继续该过程(打开和关闭).我不想使用计时器.


This code works fine to turn on screen saver.

I need another method like TurnOnScreenSaver() that stops the screen saver. I wanna turn on the screen saver first (already done) then on a specific condition I wanna turn off the screen saver and continue the process(on and off). I don''t wanna use Timer.

推荐答案


这篇关于以编程方式关闭屏幕保护程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-23 01:08