如何让Ctrl+Alt+Del 组合键无效

来源:岁月联盟 编辑:zhu 时间:2007-02-01
这将涉及到两种情况:
1.按下Ctrl+Alt+Del后,不会调出Windows的结束任务对话框
2.按下Ctrl+Alt+Del后,会调出Windows的结束任务对话框,但本程序不出现在其中
下面分别说明:
第一种情况
可调用SystemParametersInfo API 函数,细节如下:
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)
如想将Ctrl+ALt+Del 的功能还原,只需将True换为False
注意:此方案只适用于Windows 9X,NT不适用
第二种情况:(译自vb-world.net)
要想做到这一点,你必须将你的程序注册为一个Service,这将通过把你的应用程序的Process
ID传递给RegisterService API
声明部分:
将一下这些代码复制到模块的声明部分
Public Declare Function GetCurrentProcessId _
Lib "kernel32" () As Long
Public Declare Function GetCurrentProcess _
Lib "kernel32" () As Long
Public Declare Function RegisterServiceProcess _
Lib "kernel32" (ByVal dwProcessID As Long, _
ByVal dwType As Long) As Long
Public Const RSP_SIMPLE_SERVICE = 1
Public Const RSP_UNREGISTER_SERVICE = 0
过程:
调用MakeMeService使你的程序不出现在结束任务对话框中
Public Sub MakeMeService()
Dim pid As Long
Dim reserv As Long
pid = GetCurrentProcessId()
regserv = RegisterServiceProcess(pid, RSP_SIMPLE_SERVICE)
End Sub
使你的程序重新出现在结束任务对话框中,调用UnMakeMeService
Public UnMakeMeService()
Dim pid As Long
Dim reserv As Long
pid = GetCurrentProcessId()
regserv = RegisterServiceProcess(pid, _
RSP_UNREGISTER_SERVICE)
'End Code
不要忘了在关闭你的程序时调用UnMakeService来注销其Service来释放系统资源