I know it can't be done, however I have located a work around and I am seeking input from other developers as to thoughts (possible crashes, tangles etc)
This seems to be a viable solution if your goal is only to prevent the user from using task manager. If you put this in a timer with a Interval of 1 then the instant task mangager comes up an alt f4 is sent closing it.
On Error GoTo exitsub
AppActivate "Windows Task Manager"
thesendkeys = "%{F4}"
SendKeys (thesendkeys)
Exit Sub
exitsub:
Exit Sub
the othe soluton I found was:
'Place the following code in a module
Option Explicit
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Const WM_CLOSE = &H10
'THIS WILL CLOSE AN APP BY CAPTION ONLY
Public Sub CloseProgram(ByVal Caption As String)
On Error GoTo EVT
Dim lngWin As Long
lngWin = FindWindow(vbNullString, Caption)
If lngWin = 0 Then Exit Sub
SendMessage lngWin, WM_CLOSE, 0&, 0&
Exit Sub
EVT:
Err.Clear
Resume Next
End Sub
Call the code above by Call CloseProgram("My Applications Caption"
Please note that the code above will terminate without notice if an error occurs.
So, Input? houghts? Experiences?
This seems to be a viable solution if your goal is only to prevent the user from using task manager. If you put this in a timer with a Interval of 1 then the instant task mangager comes up an alt f4 is sent closing it.
On Error GoTo exitsub
AppActivate "Windows Task Manager"
thesendkeys = "%{F4}"
SendKeys (thesendkeys)
Exit Sub
exitsub:
Exit Sub
the othe soluton I found was:
'Place the following code in a module
Option Explicit
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Const WM_CLOSE = &H10
'THIS WILL CLOSE AN APP BY CAPTION ONLY
Public Sub CloseProgram(ByVal Caption As String)
On Error GoTo EVT
Dim lngWin As Long
lngWin = FindWindow(vbNullString, Caption)
If lngWin = 0 Then Exit Sub
SendMessage lngWin, WM_CLOSE, 0&, 0&
Exit Sub
EVT:
Err.Clear
Resume Next
End Sub
Call the code above by Call CloseProgram("My Applications Caption"
Please note that the code above will terminate without notice if an error occurs.
So, Input? houghts? Experiences?