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 to check if a process has really been started?

how to check if a process has really been started?

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
9 Posts 6 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.
  • T Offline
    T Offline
    ThinkingPrometheus
    wrote on last edited by
    #1

    hiho@ll you can start a new process with CreateProcess (or system,...) i think everybody knows my question: (i think it will only work with creatprocess function) how can i know if the process has really been started? (maybe the file has been deleted, or the app i want to start is single instance app and another instance is running, or the file has been damaged during download ,...) how do i know what happend and if the process has been started or not, and if not, why not thx@ll

    T C D T 4 Replies Last reply
    0
    • T ThinkingPrometheus

      hiho@ll you can start a new process with CreateProcess (or system,...) i think everybody knows my question: (i think it will only work with creatprocess function) how can i know if the process has really been started? (maybe the file has been deleted, or the app i want to start is single instance app and another instance is running, or the file has been damaged during download ,...) how do i know what happend and if the process has been started or not, and if not, why not thx@ll

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      your process should appear in the task manager...


      TOXCCT >>> GEII power
      [toxcct][VisualCalc]

      T 1 Reply Last reply
      0
      • T ThinkingPrometheus

        hiho@ll you can start a new process with CreateProcess (or system,...) i think everybody knows my question: (i think it will only work with creatprocess function) how can i know if the process has really been started? (maybe the file has been deleted, or the app i want to start is single instance app and another instance is running, or the file has been damaged during download ,...) how do i know what happend and if the process has been started or not, and if not, why not thx@ll

        C Offline
        C Offline
        Cedric Moonen
        wrote on last edited by
        #3

        Technicaly, the answer of toxcct is correct :-). But I suppose you want to check that in your code ? I think one solution could be to use the handle of the process that is 'supplied' in the LPPROCESS_INFORMATION structure after CreateProcess is called. Then, with that handle, you can call GetExitCodeStatus and check if the lpExitCode == STILL_ACTIVE . Hope this helps

        T 1 Reply Last reply
        0
        • T toxcct

          your process should appear in the task manager...


          TOXCCT >>> GEII power
          [toxcct][VisualCalc]

          T Offline
          T Offline
          ThinkingPrometheus
          wrote on last edited by
          #4

          this means i have to check what processes are currently running 1. don't really know how i can check this, using my prog :-( 2. what if it's a single instance app and i check the task manager i will find the process, but it's not the process i wanted to start! it's another! so how can i check if the process i wanted to start has been started? thx

          B 1 Reply Last reply
          0
          • C Cedric Moonen

            Technicaly, the answer of toxcct is correct :-). But I suppose you want to check that in your code ? I think one solution could be to use the handle of the process that is 'supplied' in the LPPROCESS_INFORMATION structure after CreateProcess is called. Then, with that handle, you can call GetExitCodeStatus and check if the lpExitCode == STILL_ACTIVE . Hope this helps

            T Offline
            T Offline
            ThinkingPrometheus
            wrote on last edited by
            #5

            thx i'll check it ;-)

            1 Reply Last reply
            0
            • T ThinkingPrometheus

              hiho@ll you can start a new process with CreateProcess (or system,...) i think everybody knows my question: (i think it will only work with creatprocess function) how can i know if the process has really been started? (maybe the file has been deleted, or the app i want to start is single instance app and another instance is running, or the file has been damaged during download ,...) how do i know what happend and if the process has been started or not, and if not, why not thx@ll

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              While you can use GetExitCodeThread() for this, a well-behaved application should not be concerned with what other threads are doing. By having threads communicate back and forth, you've effectively added an unnecessary level of complication to the application. The primary thread should create the other threads, give them a job to do, and then go off and do something else while not waiting around wondering about those threads. These other threads can then communicate back to the primary thread (e.g., PostMessage()) as to what their status is.


              "One must learn from the bite of the fire to leave it alone." - Native American Proverb

              -- modifed at 13:45 Thursday 25th August, 2005

              1 Reply Last reply
              0
              • T ThinkingPrometheus

                this means i have to check what processes are currently running 1. don't really know how i can check this, using my prog :-( 2. what if it's a single instance app and i check the task manager i will find the process, but it's not the process i wanted to start! it's another! so how can i check if the process i wanted to start has been started? thx

                B Offline
                B Offline
                Blake Miller
                wrote on last edited by
                #7

                If CreateProcess returns TRUE, then the process was started. If the program is a windowed application, you can use WaitforInputIdle to make sure it got a window up on the screen. A well-deisgned application that is only going ot allow a single instance to run would terminate before displaying any user interface. So if WaitForInputIdle times out, your other app is slow, or stopped. If you think it stopped, you can test the process handle to see if the handle is signaled - they are signaled if application is no longer running. You can use the process identifier returned from the CreateProcess call and compare it with the results of a call to EnumProcesses to see if the process identifier is still present.

                T 1 Reply Last reply
                0
                • T ThinkingPrometheus

                  hiho@ll you can start a new process with CreateProcess (or system,...) i think everybody knows my question: (i think it will only work with creatprocess function) how can i know if the process has really been started? (maybe the file has been deleted, or the app i want to start is single instance app and another instance is running, or the file has been damaged during download ,...) how do i know what happend and if the process has been started or not, and if not, why not thx@ll

                  T Offline
                  T Offline
                  TheGreatAndPowerfulOz
                  wrote on last edited by
                  #8

                  look into WaitForInputIdle()

                  1 Reply Last reply
                  0
                  • B Blake Miller

                    If CreateProcess returns TRUE, then the process was started. If the program is a windowed application, you can use WaitforInputIdle to make sure it got a window up on the screen. A well-deisgned application that is only going ot allow a single instance to run would terminate before displaying any user interface. So if WaitForInputIdle times out, your other app is slow, or stopped. If you think it stopped, you can test the process handle to see if the handle is signaled - they are signaled if application is no longer running. You can use the process identifier returned from the CreateProcess call and compare it with the results of a call to EnumProcesses to see if the process identifier is still present.

                    T Offline
                    T Offline
                    ThinkingPrometheus
                    wrote on last edited by
                    #9

                    thx blake seems simple i'll check it out

                    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