如何启动屏幕保护程序

当前屏幕保护程序在注册表中的位置:

HKEY_CURRENT_USER/Control Panel/Desktop

As for starting an exe in C#:
Process myProcess = Process.Start(ScreenSaverPath);

 

 

VB.NET中可用如下代码:

Private Declare Function GetDesktopWindow Lib "user32" () As Integer
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
        (ByVal hWnd As Integer, ByVal wMsg As Integer, _
        ByVal wParam As Integer, ByRef lParam As Integer) As Integer

    Const WM_SYSCOMMAND As Integer = &H112
    Const SC_SCREENSAVE As Integer = &HF140

    Private Shared Sub StartScreenSaver()
        Dim hWnd As Integer
        hWnd = GetDesktopWindow()
        SendMessage(hWnd, WM_SYSCOMMAND, SC_SCREENSAVE, 0)
    End Sub

 Visual Basic 6中可用如下代码:

[general declarations]
#If Win32 Then
    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
    Const WM_SYSCOMMAND = &H112&
    Const SC_SCREENSAVE = &HF140&
#Else
    Private Declare Function SendMessage Lib "User" (ByVal _ hWnd
        As Integer, ByVal wMsg As Integer, ByVal wParam As _ Integer,
        lParam As Any) As Long
    Const WM_SYSCOMMAND = &H112
    Const SC_SCREENSAVE = &HF140&
#End If

Private Sub Command1_Click()
    Dim result As Long
    result = SendMessage(Form1.hWnd, WM_SYSCOMMAND, _
        SC_SCREENSAVE, 0&)
End Sub

通过命令行启动:

start C:/WINDOWS/system32/ssflwbox.scr /s

 

你可能感兴趣的:(如何启动屏幕保护程序)