1,105,556 Community Members

Turn Off Your Monitor

Member Avatar
Reputation Points: 109 [?]
Q&As Helped to Solve: 73 [?]
Skill Endorsements: 0 [?]
 
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
        }
    }
Member Avatar
jfarrugia
Junior Poster
112 posts since May 2011
Reputation Points: 6 [?]
Q&As Helped to Solve: 16 [?]
Skill Endorsements: 0 [?]
 
0
 

nice!!

Member Avatar
Joshua Kidd
Junior Poster
108 posts since Feb 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Thats cool.

Member Avatar
samee1985
Newbie Poster
7 posts since Aug 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
bhagawatshinde
Posting Whiz
338 posts since Sep 2010
Reputation Points: 11 [?]
Q&As Helped to Solve: 22 [?]
Skill Endorsements: 0 [?]
 
0
 

use namespace

using System.Runtime.InteropServices;
You
Post:
Start New Discussion
Tags Related to this Article