'This will prevent the task manager from appearing
'when the user presses Ctrl+Alt+Del. This will also disable the
'Alt+Tab and the Ctrl+Esc key combinations.
Public Sub AntiTaskManagerController(Enabled As Boolean)
On Error Resume Next
If IsWinNT Then
Call NTController(TASK_MGR, Enabled) 'control the task manager in registry
If Enabled Then
Close #1 'Close the Taskmgr.exe, so we can run task manager normally
Else
Dim TMHwnd As Long
Dim ProcID As Long
Dim ProcessName As Long
Dim retVal As Long
'If task manager opened we closed it first as we can't open an opened file
TMHwnd = FindWindow("#32770", "Windows Task Manager") 'Find the HWnd of task manager
retVal = GetWindowThreadProcessId(TMHwnd, ProcID) 'Find the process id
ProcessName = OpenProcess(&H1F0FFF, 0&, ProcID) 'Open the process
retVal = TerminateProcess(ProcessName, 0&) 'Terminate it back
Open Environ("WinDir") & "\System32\Taskmgr.exe" For Input Lock Read Write As #1
End If
Else
SystemParametersInfo 97, Enabled, Enabled, 0
End If
End Sub
'This will enable or disable the windows task manager. Please note that
'this procedure does not work on any Non-NT based system (win 9x)
Public Sub NTController ( ByVal EnmPrivilage As EnumNTSettings, ByVal Enabled As Boolean)
If Not IsWinNT Then Exit Sub
Dim Command As String 'holds the Value to open
'Get the text to for the registry value for the selected setting
Select Case EnmPrivilage
Case CHANGE_PASSWORD: Command = "DisableChangePassword" 'Don't allow pasword change
Case LOCK_WORKSTATION: Command = "DisableLockWorkStation" 'Disabling locking of workstation
Case REGISTRY_TOOLS: Command = "DisableRegistryTools" 'Cancel the register tools, like regedit
Case TASK_MGR: Command = "DisableTaskMgr" 'Cancel task manager
Case DISP_APPEARANCE_PAGE: Command = "NoDispAppearancePage" 'No Display properties page
Case DISP_BACKGROUND_PAGE: Command = "NoDispBackgroundPage" 'No Background properties page
Case DISP_CPL: Command = "NoDispCPL" 'Don't Display CPLs
Case DISP_SCREENSAVER: Command = "NoDispScrSavPage" 'No Screen saver any more
Case DISP_SETTINGS: Command = "NoDispSettingsPage" 'No setting page any more
Case Else: Exit Sub
End Select
If IsWinNT Then
Call CreateRegLong(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Policies\System", Command, Not Enabled)
If IsW2000 Then Call CreateRegLong(HKEY_CURRENT_USER, _
"Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\LocalUser\Software\Microsoft\Windows\CurrentVersion\Policies\System", _
Command, Not Enabled)
End If
End Sub