Dim DisAlt As Boolean
Dim AltUp As Boolean
Dim CtrlAlt As Boolean
Dim LastKey As Integer
Const SPI_SCREENSAVERRUNNING = 97
Private Declare Function ReadPort Lib "io.dll" (ByVal Address As Long) As Byte
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 Sub Command1_Click()
Dim pOld As Boolean
Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, pOld, 0)
DisAlt = True
Label1.Caption = "状态:禁止Ctrl+Alt_Del"
End Sub
Private Sub Command2_Click()
Dim pOld As Boolean
Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, pOld, 0)
DisAlt = False
Label1.Caption = "状态:允许Ctrl+Alt_Del"
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim W As Byte
AltUp = False
LastKey = 0
If Shift = 6 And DisAlt = True Then
Do While AltUp = False
CtrlAlt = True
DoEvents
Loop
Else
CtrlAlt = False
End If
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
AltUp = True
If LastKey = ReadPort(&H60) And LastKey = 184 And CtrlAlt = True Then
MsgBox "你按了Ctrl + Alt +Del 键!", vbOKOnly + vbInformation, "提示"
LastKey = 0
End If
LastKey = ReadPort(&H60)
End Sub
Private Sub Form_Load()
Dim pOld As Boolean
Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, pOld, 0)
DisAlt = False
AltUp = False
CtrlAlt = False
Label1.Caption = "状态:允许Ctrl+Alt_Del"
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim pOld As Boolean
Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, pOld, 0)
End Sub
祝您好运!
禁止使用 Alt-Tab 或 Ctrl-Alt-Del
Private Declare Function EnableWindow Lib "user32" (ByVal hWnd As Integer, ByVal aBOOL As Integer) As Integer
Private Declare Function IsWindowEnabled Lib "user32" (ByVal hWnd As Integer) As Integer
Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Integer) As Integer
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
Private TaskBarhWnd As Long
Private IsTaskBarEnabled As Integer
Private TaskBarMenuHwnd As Integer
'禁止或允许使用 Alt-Tab
Sub FastTaskSwitching(bEnabled As Boolean)
Dim X As Long, bDisabled As Long
bDisabled = Not bEnabled
X = SystemParametersInfo(97, bDisabled, CStr(1), 0)
End Sub
'禁止使用Ctrl-Alt-Del
Public Sub DisableTaskBar()
Dim EWindow As Integer
TaskBarhWnd = FindWindow("Shell_traywnd", "")
If TaskBarhWnd <> 0 Then
EWindow = IsWindowEnabled(TaskBarhWnd)
If EWindow = 1 Then
IsTaskBarEnabled = EnableWindow(TaskBarhWnd, 0)
End If
End If
End Sub
'允许使用Ctrl-Alt-Del
Public Sub EnableTaskBar()
If IsTaskBarEnabled = 0 Then
IsTaskBarEnabled = EnableWindow(TaskBarhWnd, 1)
End If
End Sub
禁止 Ctrl+Alt+Del
声明(For Win95):
Const SPI_SCREENSAVERRUNNING = 97
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
使用:
'禁止
Dim pOld As Boolean
Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, pOld, 0)
'开启
Dim pOld As Boolean
Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, pOld, 0)
UINT uiAction, // system parameter to query or set
UINT uiParam, // depends on action to be taken
PVOID pvParam, // depends on action to be taken
UINT fWinIni // user profile update flag
);
VC的:
int NoUse;
//...其他程序
SystemParametersInfo( SPI_SCREENSAVERRUNNING, 0, &NoUse, 0);//设置成屏保模式