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

namespace Helper {
    
public class MonitorHelper {
        
public static void TurnOn() {
            SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 
-1);
        }


        
public static void TurnOff() {
            SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 
2);
        }


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

        
private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
        
private const uint WM_SYSCOMMAND = 0x0112;
        
private const int SC_MONITORPOWER = 0xf170;
    }

}

posted on 2009-09-07 15:33  ю意思я  阅读(298)  评论(0编辑  收藏  举报