How To Switch Off Your LCD Monitor With VB.NET

this is something very cool , this will switch off your monitor i tested this on LCD so just you can add a button and double click the form and erase everything and add this and try it out


Imports System.Runtime.InteropServices
Public Class form1
    Private Const MONITOR_OFF As Integer = 2
    Private SC_MONITORPOWER As Integer = &HF170
    Private WM_SYSCOMMAND As Integer = &H112
     _
    Private Shared Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
    End Function
     _
    Private Shared Function SendMessage(ByVal hWnd As Integer, ByVal hMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    End Function
    Public Sub SwitchOffLCD()
        Dim num As Integer = 0
        num = SendMessage(FindWindow(Nothing, Nothing).ToInt32, Me.WM_SYSCOMMAND, Me.SC_MONITORPOWER, 2)
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        SwitchOffLCD()
    End Sub
End Class

enjoy

1 comments:

An Easier Way:

Public WM_SYSCOMMAND As Integer = &H112
Public SC_MONITORPOWER As Integer = &HF170

_
Private Shared Function SendMessage(ByVal hWnd As Integer, ByVal hMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function

Private Sub MonitorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MonitorToolStripMenuItem.Click
SendMessage(Me.Handle.ToInt32(), WM_SYSCOMMAND, SC_MONITORPOWER, 2)
End Sub

Reply

Post a Comment