I just had a quick go and got this code working in a winform app:
vb Code:
Const SC_MONITORPOWER As Integer = 61808 Const WM_SYSCOMMAND As Integer = 274 Const MONITOR_OFF As Integer = 2 Partial Public Class API <System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint:="SendMessage")> _ Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Integer End Function End Class Private Sub Offbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Offbtn.Click API.SendMessage(Me.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_STANDBY) End Sub
Turns the monitor off as soon as Offbtn is clicked![]()





Reply With Quote