从C#Windows窗体启动系统屏幕保护程序 [英] Launch System Screensaver from C# Windows Form

查看:289
本文介绍了从C#Windows窗体启动系统屏幕保护程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望这是一个简单的,但任何人都可以提供一些简单的C#code,将推出当前配置的屏幕保护程序?

Hopefully this is a simple one, but can anyone provide some simple c# code that will launch the currently configured screensaver?

推荐答案

下面是显示如何使用屏幕保护程序的各方面工作的好发部位。查看评论在年底为code以启动屏幕保护程序。

Here is a good site showing how to work with all aspects of the screensaver. See the comments at the end for the code to start the screensaver.

<一个href=\"http://www.$c$cproject.com/KB/cs/ScreenSaverControl.aspx\">http://www.$c$cproject.com/KB/cs/ScreenSaverControl.aspx

    [DllImport("user32.dll", EntryPoint = "GetDesktopWindow")]
    private static extern IntPtr GetDesktopWindow();

    [DllImport("user32.dll")]
    private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);

    //...

    private const int SC_SCREENSAVE = 0xF140;
    private const int WM_SYSCOMMAND = 0x0112;

    //...

    public static void SetScreenSaverRunning()
    {
    SendMessage

(GetDesktopWindow(), WM_SYSCOMMAND, SC_SCREENSAVE, 0);
}

这篇关于从C#Windows窗体启动系统屏幕保护程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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