Launch Screen Saver

'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Add 1 CommandButton to your form (named Command1),
'When you will press the button the screen saver will be launched.
'Insert this code to the module :

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

'Insert this code to your form:

Private Sub Command1_Click()
Dim lResult As Long
x = GetActiveWindow
Const WM_SYSCOMMAND = &H112
Const SC_SCREENSAVE = &HF140
lResult = SendMessage(x, WM_SYSCOMMAND, SC_SCREENSAVE, 0&)
End Sub

Go Back