1.11M Members

Turn Off Your Monitor

 
4
 

Turn you Monitor off from your application.

public partial class Form1 : Form
    {
        public int WM_SYSCOMMAND = 0x0112;
        public int SC_MONITORPOWER = 0xF170; 
        [DllImport("user32.dll")]
        private static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SendMessage( this.Handle.ToInt32() , WM_SYSCOMMAND , SC_MONITORPOWER ,2 );//DLL function
        }
    }
 
0
 

nice!!

 
0
 

Thats cool.

 
0
 

it does not work
please help.

Error 1 The type or namespace name 'DllImport' could not be found (are you missing a using directive or an assembly reference?) E:\Windows Application\TEST APPLICATION\TurnOffMonitor\TurnOffMonitor\Form1.cs 19 10 TurnOffMonitor

 
0
 

use namespace

using System.Runtime.InteropServices;
Isn't it about time forums rewarded their contributors?

Earn rewards points for helping others. Gain kudos. Cash out. Get better answers yourself.

It's as simple as contributing editorial or replying to discussions labeled or OP Kudos

You
This is an OP Kudos discussion and contributors may be rewarded
Post:
Start New Discussion
Tags Related to this Article