HowTo wake up from screen saver from a VB.NET application

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, I need to write down a VB.NET program that, remotely called, wakes up
one PC (XP box) from the ScreenSaver Satus ...

I found this chunk of code somewhere in the Internet ... but I can't get it
working ....... can someone help me in undersatnding why ? or suggesting
something different. Thanks in advance Daniele Balducci

Private Const SC_SCREENSAVE = &HF140&
Private Const WM_SYSCOMMAND = &H112
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam
As Long) As Long
Declare Function GetDesktopWindow Lib "user32" () As Long


Sub ScreenSaver(ByVal blnScreenSaver As Boolean)
Dim lState As Long
Dim lHwnd As Long

If blnScreenSaver Then
lState = 1
Else
lState = -1
End If

lHwnd = GetDesktopWindow()
SendMessage(lHwnd, WM_SYSCOMMAND, SC_SCREENSAVE, lState)

End Sub
 
Back
Top