Chase Down My Dream

Life, Dream

  • Home
  • About
  • Sample Page
Twitter Facebook Sina RSS
Tag Archives: Monitor

C# 关闭显示器

Posted on August 21, 2009 by stingrey
10 Comments

午休期间无聊刷代码写的软件,程序大小101K,其中ico文件100K。。。
下载:CloseMonitor.zip
放在桌面,双击使用即可,实际上是使屏幕进入节能模式,鼠标或者键盘按键产生位移就会恢复。
就几行代码:

using System;using System.Collections.Generic;using System.Text;using System.Runtime.InteropServices;

namespace CloseMonitor{    class CloseMonitor    {        static void Main(string[] args)        {            CloseMonitor CM = new CloseMonitor();            CM.CloseMonitorMethod();        }

        #region SendMessage        private const uint WM_SYSCOMMAND = 0x0112;        private const uint SC_MONITORPOWER = 0xF170;        static readonly IntPtr HWND_HANDLE = new IntPtr(0xffff);        [DllImport("user32")]        public static extern IntPtr SendMessage(IntPtr hWnd, uint wMsg, uint wParam, int lParam);        #endregion

        public void CloseMonitorMethod()        {            SendMessage(HWND_HANDLE, WM_SYSCOMMAND, SC_MONITORPOWER, 2);        }    }}

百度空间的缩进是点点点啊点点点~

Categories: C# | Tags: C#, Monitor
  • Recent Posts

    • 一年了,我回来了
    • Un Senso Di Te
    • 好雨时节
    • 虎年来在追昔时
    • 无题
  • Recent Comments

    • hzqtc on 一年了,我回来了
    • aaahexing on Un Senso Di Te
    • RainFlying on 好雨时节
    • Stingrey on 秦时明月,侠骨柔情
    • hzqtc on 被拒了~
  • Archives

    • November 2011
    • June 2010
    • April 2010
    • February 2010
    • December 2009
    • November 2009
    • October 2009
    • September 2009
    • August 2009
    • July 2009
    • June 2009
    • May 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
    • September 2008
    • July 2008
  • Categories

    • C#
    • Google App Engine
    • Hello Program
    • Linux
    • Linux and Windows
    • Micolog
    • Misc
    • Mojo
    • Music and Movie
    • Windows
    • 另一个自己
    • 玩意儿
    • 生活
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
© Chase Down My Dream. Proudly Powered by WordPress | Nest Theme by YChong