Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to forbid the user to terminate my program.

How to forbid the user to terminate my program.

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
8 Posts 8 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 2006398
    wrote on last edited by
    #1

    How to forbid the user to terminate my program.(in taskmgr). Can I accomplish that to promote the process privilege.Thanks for your help.

    Steve EcholsS J S M 4 Replies Last reply
    0
    • M Member 2006398

      How to forbid the user to terminate my program.(in taskmgr). Can I accomplish that to promote the process privilege.Thanks for your help.

      Steve EcholsS Offline
      Steve EcholsS Offline
      Steve Echols
      wrote on last edited by
      #2

      Why would you want to do that? Are you writing malicious applications? If you're writing a normal application, make it so good that no-one would want to exit it. :-D


      - S 50 cups of coffee and you know it's on!

      • S
        50 cups of coffee and you know it's on!
        Code, follow, or get out of the way.
      1 Reply Last reply
      0
      • M Member 2006398

        How to forbid the user to terminate my program.(in taskmgr). Can I accomplish that to promote the process privilege.Thanks for your help.

        J Offline
        J Offline
        Joe Woodbury
        wrote on last edited by
        #3

        You can't. This is by design of windows.

        Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

        F W 2 Replies Last reply
        0
        • J Joe Woodbury

          You can't. This is by design of windows.

          Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

          F Offline
          F Offline
          flippydeflippydebop
          wrote on last edited by
          #4

          If its an important application that needs to be running 365 days of the year, it should be firstly be running on a dedicated server. The less user interaction the more chance it wont be closed by accident. You can then start by overridding the usual suspects: OnClose, OnOK, OnCancel. Although as previous replies have said, a user could still terminate the application via task manager. - Maybe writing the application as a desktop application is the wrong avenue to take in this instance and writing the program as a windows service would be more fitting. However, even though this would give you some benefits ( e.g from people logging onto the machine and mistakingly terminating the program ) you can still not guarantee that your program could not be stopped. If you really want to make sure that this application is not closed, you could write a heartbeat/pulse utility which periodically checks to make sure that your app is still running, and if its not re-start it! - then ofcourse some of the emphasis then shifts to the heartbeat/utility app. If this gets closed, then your back to step 1. - You could make the same heartbeat/pulse app distributed, in that it could be present on multiple servers, with all of them checking in with the server your 'important' app is running on. Just a few ramblings.

          1 Reply Last reply
          0
          • J Joe Woodbury

            You can't. This is by design of windows.

            Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

            W Offline
            W Offline
            wanglei1980
            wrote on last edited by
            #5

            you can create another process to monitor the main process, once the main process had been terminated, the other process create it immediately. and also the main process monitor the other process to keep it running.once it has been terminated create it immediately. i think this method may satisfy your needs.

            1 Reply Last reply
            0
            • M Member 2006398

              How to forbid the user to terminate my program.(in taskmgr). Can I accomplish that to promote the process privilege.Thanks for your help.

              S Offline
              S Offline
              Stephen Hewitt
              wrote on last edited by
              #6

              If this was easy to do every virus/trojan writer would be doing so already.

              Steve

              H 1 Reply Last reply
              0
              • S Stephen Hewitt

                If this was easy to do every virus/trojan writer would be doing so already.

                Steve

                H Offline
                H Offline
                Hamid Taebi
                wrote on last edited by
                #7

                A good answer:)

                _**


                **_

                whitesky


                1 Reply Last reply
                0
                • M Member 2006398

                  How to forbid the user to terminate my program.(in taskmgr). Can I accomplish that to promote the process privilege.Thanks for your help.

                  M Offline
                  M Offline
                  Maxwell Chen
                  wrote on last edited by
                  #8

                  Hook the terminate process API in kernel32.dll. Then when user right-click on the process list of Task Manager to kill process (tree), it takes no action.


                  Maxwell Chen

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups