Your current code should work if you will implement it the suggested modification I specified in post #3. I tried the following and it worked.
Code:Public Class Form1 Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" _ (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, _ ByVal lParam As Integer) As Integer Const HWND_BROADCAST As Integer = &HFFFF Const SC_MONITORPOWER As Integer = &HF170 Const WM_SYSCOMMAND As Short = &H112S Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2) End Sub End Class




Reply With Quote