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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top