Private Declare Function SystemParametersInfo Lib "user32" _
Alias "SystemParametersInfoA" (ByVal uAction As Long, _
ByVal uParam As Long, lpvParam As Any, _
ByVal fuWinIni As Long) As Long
Private Const SPI_SCREENSAVERRUNNING = 97
Private Sub Command1_Click()
Dim ret As Integer
Dim pOld As Boolean
If Command1.Caption = "屏蔽" Then '使Ctrl+Alt+Del有效
ret = SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, pOld, 0)
Command1.Caption = "有效"
Else '使Ctrl+Alt+Del无效
ret = SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, pOld, 0)
Command1.Caption = "屏蔽"
End If
End Sub
Private Sub Form_Load()
Command1.Caption = "屏蔽"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim ret As Integer
Dim pOld As Boolean
'退出前使ALT+CTL+DEL有效
ret = SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, pOld, 0)
End Sub
'显示开始按钮
Dim hLong As Long
Dim hWnd As Long
hWnd = FindWindow("Shell_TrayWnd", vbNullString)
hLong = FindWindowEx(hWnd, 0, "Button", vbNullString)
ShowWindow hLong, SW_SHOW
'声明
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Const SW_HIDE = 0
Private Const SW_SHOW = 5
Private Const SW_SHOWNORMAL = 1
'屏蔽开始按钮
Dim hLong As Long
Dim hWnd As Long
hWnd = FindWindow("Shell_TrayWnd", vbNullString)
hLong = FindWindowEx(hWnd, 0, "Button", vbNullString)
ShowWindow hLong, SW_HIDE