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;
        }
    }
  • 相关阅读:
    C++异常:exception
    C++关键字:explicit
    C++关键字:重学记录
    Unity jointmoto
    hashtable和hashmap
    Spring MVC 笔记 概述
    SQL上门2
    面试:A
    Java 初学者
    SQL上门
  • 原文地址:https://www.cnblogs.com/xpvincent/p/2944629.html
Copyright © 2011-2022 走看看