Programing

모니터 C#으로 끄기

ned3y2k 2013. 9. 3. 10:27

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;


using System.Runtime.InteropServices;


namespace WindowsFormsApplication1

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }


        const int WM_SYSCOMMAND = 0x0112;

        const int SC_MONITORPOWER = 0xF170;

        const int ON = -1;

        const int OFF = 2;


        [DllImport("user32.dll", SetLastError = true)]

        private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);



        private void button1_Click(object sender, EventArgs e)

        {

            SendMessage(this.Handle, WM_SYSCOMMAND, new IntPtr(SC_MONITORPOWER), new IntPtr(OFF));

        }

    }

}


참고문서: http://www.kev009.com/wp/projects/lcdoff/


첨부파일: LCDoff.zip 은 어셈으로 작성된 코드이다.