Rutina en vb.net para prender y apagar el monitor usando la función del api
postMessage
Código fuenteOption Explicit On
Public Class Form1
' función PostMessage
Public Declare Function PostMessage Lib "user32.dll" _
Alias "PostMessageA" (ByVal hwnd As IntPtr,ByVal wMsg As Int32, _
ByVal wParam As Int32,ByVal lParam As Int32) As Int32
' Contantes
Private Const WM_SYSCOMMAND = &H112&
Private Const SC_MONITOR_POWER = &HF170&
Private Const MONITOR_ON = -1
Private Const MONITOR_OFF = 2
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
' prende el monitor
'''''''''''''''''''''''
'PostMessage(Me.Handle, WM_SYSCOMMAND, SC_MONITOR_POWER, MONITOR_ON)
' standby
'''''''''''''''''''''''
'PostMessage(Me.Handle, WM_SYSCOMMAND, SC_MONITOR_POWER, MONITOR_OFF)
End Sub
End Class
Public Class Form1
' función PostMessage
Public Declare Function PostMessage Lib "user32.dll" _
Alias "PostMessageA" (ByVal hwnd As IntPtr,ByVal wMsg As Int32, _
ByVal wParam As Int32,ByVal lParam As Int32) As Int32
' Contantes
Private Const WM_SYSCOMMAND = &H112&
Private Const SC_MONITOR_POWER = &HF170&
Private Const MONITOR_ON = -1
Private Const MONITOR_OFF = 2
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
' prende el monitor
'''''''''''''''''''''''
'PostMessage(Me.Handle, WM_SYSCOMMAND, SC_MONITOR_POWER, MONITOR_ON)
' standby
'''''''''''''''''''''''
'PostMessage(Me.Handle, WM_SYSCOMMAND, SC_MONITOR_POWER, MONITOR_OFF)
End Sub
End Class
No hay comentarios:
Publicar un comentario