Const WM_SYSCOMMAND = &H112&
Const SC_MONITORPOWER = &HF170&
' VB6 宣告之 Long 得改成 Int32 (Integer)
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Int32)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SendMessage(Me.Handle.ToInt32, WM_SYSCOMMAND, SC_MONITORPOWER, 1&) ' 關閉螢幕
Sleep(10000) '暫停10秒
SendMessage(Me.Handle.ToInt32, WM_SYSCOMMAND, SC_MONITORPOWER, -1&) '啟動螢幕
End Sub
沒有留言:
張貼留言