Re: Preventing End Task

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Steve Gerrard (mynamehere_at_comcast.net)
Date: 01/06/05


Date: Thu, 6 Jan 2005 07:40:35 -0800


"Suja" <sujamoljames@yahoo.com> wrote in message
news:1105015271.118546.109890@f14g2000cwb.googlegroups.com...
| Hi All,
|
| I have a process listed in Task Manager. When the user do End Task, i
| want to prevent this.
|
| I am not planning to move this process as a service due to technical
| constrains ( Admin Rights issue)
|
| 1) Alleast I need to show a error message like " Crtical process can't
| terminate" same as winlogon.exe
| 2) How to hide my exe from task manager?
|
|
| Thanks in advance
| Suja
|

Assuming you have a main form for your app, put a handler in the query
unload event of the main form:

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

The UnloadMode value will tell you why the form is being unloaded:

vbFormControlMenu
    The user chose the Close command from the Control menu on the form.
vbFormCode
    The Unload statement is invoked from code.
vbAppWindows
    The current Microsoft Windows operating environment session is
ending.
vbAppTaskManager
    The Microsoft Windows Task Manager is closing the application.
vbFormMDIForm
    An MDI child form is closing because the MDI form is closing.
vbFormOwner
    A form is closing because its owner is closing.

You can do a select case on UnloadMode if you need different responses.
You can then pop up a message to the user, and set Cancel = True if you
(or they) want to cancel the unload operation.

In some cases, i.e. the session is ending, Windows may close the
application anyway, but at least you can warn the user this way.



Relevant Pages

  • Re: Preventing End Task
    ... | I have a process listed in Task Manager. ... vbFormControlMenu ... The Unload statement is invoked from code. ... The Microsoft Windows Task Manager is closing the application. ...
    (microsoft.public.win32.programmer.networks)
  • Re: Problems with users closing forms.
    ... Thank you Rick, a change of perspective on this problem is exactly what I ... I figured all I had to do was move the Refresh to the Unload ... >> the Access application window from closing by using the OkToClose ... >> simply right-clicking on the form name in the task bar and then ...
    (microsoft.public.access.forms)
  • Re: Notification of WIndows Shutdown.
    ... application derived shutdown. ... The Unload statement is invoked from code. ... The current Microsoft Windows operating environment session is ending. ... The Microsoft Windows Task Manager is closing the application. ...
    (microsoft.public.vb.general.discussion)
  • Re: Notification of WIndows Shutdown.
    ... application derived shutdown. ... The Unload statement is invoked from code. ... The current Microsoft Windows operating environment session is ending. ... The Microsoft Windows Task Manager is closing the application. ...
    (microsoft.public.vb.general.discussion)
  • Re: Notification of WIndows Shutdown.
    ... The Unload statement is invoked from code. ... The current Microsoft Windows operating environment session is ending. ... The Microsoft Windows Task Manager is closing the application. ...
    (microsoft.public.vb.general.discussion)