Own Windows Tools With C# (Part 1): Custom Monitor Turn Off


Hey friends, i m going to start new part in this blog where we will make some windows tools by using windows libraries. it customize application made just make windows more easy to use. if you have any idea about it share it with us.

Now i m going to make a application that will shutdown my monitor on one click. Some time we need to turn off monitor we press button of power or monitor but by using this custom application you can easily turn off your monitor and no power issue will be happened.

How to make it???

Create New windows Projects. Form style depend on you what you want. Drag button from tool box double click on button, then you get button click event.

Now write following code to add
interopservices
using System.Runtime.InteropServices;

then following code write as class level.
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);

in above code we are calling user32.dll, this library holds all operation like this.


Now come to the button click event and write this code..

SendMessage(this.Handle.ToInt32(), WM_SYSCOMMAND, SC_MONITORPOWER, 2);

Now enjoy your own application with windows component.
Download Sample
if you like the post response me in form of comment. and contact me for further detail. Soon i will back with new custom tool. Take Care

0 comments

Post a Comment

 
|  I Code Help. Blogger Template By Lawnydesignz Powered by Blogger