CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Guest

    Trapping when exe is killed from Task Manager

    How to deny the access to user from killing MFC dialog based application from
    Task Manager (Terminate process) or atleast get notified when it is killed

    You can mail to [email protected]



  2. #2
    Join Date
    Jan 2000
    Location
    Portugal
    Posts
    239

    Re: Trapping when exe is killed from Task Manager

    Strange.... are you trying to develop something that prevents the owner of the machine/program from decide what should be running or not? Really weird indeed. I think that can't be done, anyway, have you seen it somewhere ?

    Regarding "get notified when killed", i think Windows has a funny way to KILL processes. It just removes the thread without first sending KILL message to clean things nicely. So i guess you don't have a chance here either...



    --
    Nuno Tavares
    http://nthq.cjb.net
    Nuno Tavares
    "I live the way I type: fast, with a lot of errors"

  3. #3
    Join Date
    Jan 2000
    Location
    Portugal
    Posts
    239

    Re: Trapping when exe is killed from Task Manager

    I forgot to mentio that if it is a service, and it's installed by Administrator Priviledged User (WinNT only) it won't be killed by a common user.


    --
    Nuno Tavares
    http://nthq.cjb.net
    Nuno Tavares
    "I live the way I type: fast, with a lot of errors"

  4. #4
    Join Date
    Nov 1999
    Location
    Romania
    Posts
    51

    Re: Trapping when exe is killed from Task Manager

    I don't know if it works, but it might be a solution (maybe).
    You have to make 2 applications:
    -the first one(app1) has to do the following -launch the other application(app2)
    -wait to finish (app2) and check a value returned by app2 (ex. if it is true app2 terminated normaly and if it is false app2 was killed)
    An example of application who can launch another process and wait for it to finish you can find at codeguru.com but I don't remember the exact place.

    The sad part is if the user kill app1.In this case I really don't know what to do.


    Sorry for my bad english.



    Ciprian Pavel.

    Sincerily
    Ciprian Pavel

  5. #5
    Join Date
    Nov 1999
    Location
    Romania
    Posts
    51

    Re: Trapping when exe is killed from Task Manager

    I don't know if it works, but it might be a solution (maybe).
    You have to make 2 applications:
    -the first one(app1) has to do the following -launch the other application(app2)
    -wait to finish (app2) and check a value returned by app2 (ex. if it is true app2 terminated normaly and if it is false app2 was killed)
    An example of application who can launch another process and wait for it to finish you can find at codeguru.com but I don't remember the exact place.

    The sad part is if the user kill app1.In this case I really don't know what to do.


    Sorry for my bad english.



    Sincerily
    Ciprian Pavel

  6. #6
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266

    Re: Trapping when exe is killed from Task Manager

    I think that getting "notified when it is killed" is an excellent solution. You can process the WM_CLOSE message, because the first thing that the task manager does is to send it, and I have verified that a dialog gets the message and can process the message. Hopefully in your WM_CLOSE message you will be able to do whatever cleanup is required. This is definitely the way it "should" be done. Note that you must get all the data you need to get from the dialog before calling CDialog::OnClose().



    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  7. #7
    Guest

    Re: Trapping when exe is killed from Task Manager

    When applicaton is killed through Task Manager process tab using End Process option, application will not get any wm_close message. thats the problem i had? please if u have any other solution let me know [email protected]


  8. #8
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266

    Re: Trapping when exe is killed from Task Manager

    I tested it and my dialog definitely got the close message. It works. However, I used the "End Process" on the "Applications" tab. That is what should be used when possible. The "Processes" tab should be used when the "Applications" tab cannot be used. When I used the "Processes" tab to terminate my dialog, the dialog did not get a close message.


    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured