zoukankan      html  css  js  c++  java
  • C#实现开关显示器功能

    使用C#编写了个控制显示器开关的程序。

    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;
        }
    }
  • 相关阅读:
    BOZJ2200: [Usaco2011 Jan]道路和航线
    poj3662
    网络流
    最短路
    约瑟夫环
    二分图匹配
    HDU 3938 Portal
    背包dp专题训练
    noip2013day1模拟赛
    2017.10.24:lca专题系列
  • 原文地址:https://www.cnblogs.com/xpvincent/p/2944629.html
Copyright © 2011-2022 走看看