Di bawah ini merupakan fungsi VB6 untuk mematikan layar monitor.
READ MORE - VB6 Code - Fungsi Untuk Menjadikan Blank Layar Komputer
Option ExplicitContoh penggunaan kode di atas:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const MONITOR_ON = -1&
Private Const MONITOR_LOWPOWER = 1&
Private Const MONITOR_OFF = 2&
Private Const SC_MONITORPOWER = &HF170&
Private Const WM_SYSCOMMAND = &H112
Public Function TurnOnMonitor(hwnd As Long, bFlag As Boolean) As Boolean
If bFlag Then
Call SendMessage(hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, ByVal MONITOR_ON)
Else
Call SendMessage(hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, ByVal MONITOR_OFF)
End If
End Function
Option Explicit
Private Sub Command1_Click()
TurnOnMonitor Me.hwnd, False
End Sub