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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How can I kill a Process??

How can I kill a Process??

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
6 Posts 4 Posters 0 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.
  • P Offline
    P Offline
    pavanbabut
    wrote on last edited by
    #1

    Hi, I am stuck up in the middle of killing a process created using CreateProcess within a DLL. While using ExitProcess with the crated process's exitcode, it is terminating the parent process too. Is there anyway to kill a process created within a DLL without disturbing the parent process??:confused:. BTW the process that is craeted is an exe file of a console application. thanks, -Pav. Got it, nevermind by using terminate process with process handle that was created;P ;) -- modified at 18:06 Wednesday 5th April, 2006

    G S H 3 Replies Last reply
    0
    • P pavanbabut

      Hi, I am stuck up in the middle of killing a process created using CreateProcess within a DLL. While using ExitProcess with the crated process's exitcode, it is terminating the parent process too. Is there anyway to kill a process created within a DLL without disturbing the parent process??:confused:. BTW the process that is craeted is an exe file of a console application. thanks, -Pav. Got it, nevermind by using terminate process with process handle that was created;P ;) -- modified at 18:06 Wednesday 5th April, 2006

      G Offline
      G Offline
      gamitech
      wrote on last edited by
      #2

      well you should do it with terminate process but when opening the process and obtaining the handle you should open it without inheritting from parrent. OpenProcess( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId ); DediredAccess should be PROCESS_TERMINATE and bInheritHandle should be FALSE Then terminateprocess should do the job easily; gabby

      P 1 Reply Last reply
      0
      • G gamitech

        well you should do it with terminate process but when opening the process and obtaining the handle you should open it without inheritting from parrent. OpenProcess( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId ); DediredAccess should be PROCESS_TERMINATE and bInheritHandle should be FALSE Then terminateprocess should do the job easily; gabby

        P Offline
        P Offline
        pavanbabut
        wrote on last edited by
        #3

        OpenProcess hmmm... will give it a try sometime... Thanks for your time though.. -Pav

        1 Reply Last reply
        0
        • P pavanbabut

          Hi, I am stuck up in the middle of killing a process created using CreateProcess within a DLL. While using ExitProcess with the crated process's exitcode, it is terminating the parent process too. Is there anyway to kill a process created within a DLL without disturbing the parent process??:confused:. BTW the process that is craeted is an exe file of a console application. thanks, -Pav. Got it, nevermind by using terminate process with process handle that was created;P ;) -- modified at 18:06 Wednesday 5th April, 2006

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

          Although the practice is rampart - in general it is not safe to go around calling TerminateProcess on processes. This API kills the process on the spot and as such the application doesn't have a chance to clean up after itself. For example it may result in temporary files not being deleted, files or registry entries in a corrupt state as a result of the process being terminated in the middle of an update or worse. Steve

          P 1 Reply Last reply
          0
          • S Stephen Hewitt

            Although the practice is rampart - in general it is not safe to go around calling TerminateProcess on processes. This API kills the process on the spot and as such the application doesn't have a chance to clean up after itself. For example it may result in temporary files not being deleted, files or registry entries in a corrupt state as a result of the process being terminated in the middle of an update or worse. Steve

            P Offline
            P Offline
            pavanbabut
            wrote on last edited by
            #5

            Yep, you are right. But, depending upon the application I think we can go in this way :) to get around the problem. But in intensive applications this is not something that is recommended as you said. But, for me, this is good enough as I am using to start and stop NI-Board. -Pav

            1 Reply Last reply
            0
            • P pavanbabut

              Hi, I am stuck up in the middle of killing a process created using CreateProcess within a DLL. While using ExitProcess with the crated process's exitcode, it is terminating the parent process too. Is there anyway to kill a process created within a DLL without disturbing the parent process??:confused:. BTW the process that is craeted is an exe file of a console application. thanks, -Pav. Got it, nevermind by using terminate process with process handle that was created;P ;) -- modified at 18:06 Wednesday 5th April, 2006

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

              Hi pavanbabut, maybe it is some helpful to you http://www.codeproject.com/threads/killprocess.asp[^]

              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