98可以,2000不行 '模块 Public Declare Function GetCurrentProcessId Lib “kernel32” () As Long ’获得当前进程ID函数的声明 Public Declare Function RegisterServiceProcess Lib “kernel32” (ByVal ProcessId As Long, ByVal ServiceFlags As Long) As Long '窗体Private Sub Form_Load() RegisterServiceProcess GetCurrentProcessId, 1 ’ 从系统中取消当前进程 end subPrivate Sub Form_Unload(Cancel As Integer) RegisterServiceProcess GetCurrentProcessId, 0 ’从系统中取消当前程序的进程 End Sub
快去http://www.yesky.com/20020122/214855_2.shtml看看
用SystemParametersInfoByRef,示例(win98下有效,NT无效):Option ExplicitDeclare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long Declare Function SystemParametersInfoByRef Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As LongPrivate Sub Command1_Click() Dim pOld As Boolean SystemParametersInfoByRef SPI_SCREENSAVERRUNNING, True, pOld, 0 '屏蔽 End SubPrivate Sub Command2_Click() Dim pOld As Boolean SystemParametersInfoByRef SPI_SCREENSAVERRUNNING, False, pOld, 0 '恢复 End Sub
屏蔽Ctrl+Alt+Del:Option ExplicitPrivate Declare Function GetCurrentProcessId Lib "kernel32" () As LongPrivate Declare Function GetCurrentProcess Lib "kernel32" () As LongPrivate Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As LongPrivate Const RSP_SIMPLE_SERVICE = 1Private Const RSP_UNREGISTER_SERVICE = 0 Private Sub MakeMeService() Dim pid As Long Dim reserv As Long pid = GetCurrentProcessId() RegisterServiceProcess pid, RSP_SIMPLE_SERVICEEnd Sub Private Sub UnMakeMeService() Dim pid As Long Dim reserv As Long pid = GetCurrentProcessId() RegisterServiceProcess pid, RSP_UNREGISTER_SERVICEEnd Sub Private Sub Command1_Click() Call MakeMeService 'ʹ´°¿ÚÒþ²ØEnd Sub Private Sub Command2_Click() Call UnMakeMeService 'ʹ´°¿ÚÏÔʾEnd Sub
'模块里内容 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 Sub DisableCtrlAltDelete(bDisabled As Boolean) ' Disables Control Alt Delete Breaking as well as Ctrl-Escape Dim X As Long X = SystemParametersInfo(97, bDisabled, CStr(1), 0)End Sub '窗体代码 Private Sub Command1_Click() DisableCtrlAltDelete (False) End SubPrivate Sub Command2_Click() DisableCtrlAltDelete (True) End Sub
Option Explicit Const SPI_SCREENSAVERRUNNING = 97Private 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 '=================================disable Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, "1", 0) '=================================enable Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, "1", 0)
'模块
Public Declare Function GetCurrentProcessId Lib “kernel32” () As Long
’获得当前进程ID函数的声明
Public Declare Function RegisterServiceProcess Lib “kernel32” (ByVal ProcessId As Long, ByVal ServiceFlags As Long) As Long '窗体Private Sub Form_Load()
RegisterServiceProcess GetCurrentProcessId, 1 ’ 从系统中取消当前进程
end subPrivate Sub Form_Unload(Cancel As Integer)
RegisterServiceProcess GetCurrentProcessId, 0 ’从系统中取消当前程序的进程
End Sub
Declare Function SystemParametersInfoByRef Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As LongPrivate Sub Command1_Click()
Dim pOld As Boolean
SystemParametersInfoByRef SPI_SCREENSAVERRUNNING, True, pOld, 0 '屏蔽
End SubPrivate Sub Command2_Click()
Dim pOld As Boolean
SystemParametersInfoByRef SPI_SCREENSAVERRUNNING, False, pOld, 0 '恢复
End Sub
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
Sub DisableCtrlAltDelete(bDisabled As Boolean)
' Disables Control Alt Delete Breaking as well as Ctrl-Escape
Dim X As Long
X = SystemParametersInfo(97, bDisabled, CStr(1), 0)End Sub
'窗体代码
Private Sub Command1_Click()
DisableCtrlAltDelete (False)
End SubPrivate Sub Command2_Click()
DisableCtrlAltDelete (True)
End Sub
Const SPI_SCREENSAVERRUNNING = 97Private 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
'=================================disable
Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, "1", 0)
'=================================enable
Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, "1", 0)