Switch Montior Off

Cheetah

Well-known member
Joined
Oct 12, 2006
Messages
232
Programming Experience
Beginner
Hi there,

Is there a way to switch the monitor off in VB.NET?

Thanks.

EDIT:

Also how do i reference to the directory that the published .exe is in. So i can refer to a file in the same directory.
 
I don't think you can turn it off, unless your pc has an finger it can push the button with:)
.However you can certainly send it into standby...

VB.NET:
 Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" 
(ByVal hWnd As Intptr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Int32) As Integer 
 
Const SC_MONITORPOWER As Integer = &HF170
Const MONITOR_ON As Short = -1
Const MONITOR_OFF As Short = 2
Const WM_SYSCOMMAND As Short = &H112S

To use...

VB.NET:
SendMessage([COLOR=red]HANDLE TO THE MAIN FORM GOES HERE[/COLOR], WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF)
 
Back
Top