|
It is not actually possible to suspend processes under windows. The closest is to suspend threads within the process e.g. if there is only one thread in the process, suspending it would effectively suspend the process. Look up the win32 API functions named SuspendThread() and ResumeThread(). If you've created the affected process using CreateThread(), you will have handles to both it's process and it's main thread.
If you are implementing both the program being suspended, as well as the program doing the suspending, you would be better off defining a means of communication so that you can tell the program to suspend itself (or, more accurately, not to do anything until you send it another message telling it to resume). This doesn't require stopping the thread in it's tracks (as with SuspendThread()); you can also simply stop it doing selected actions. This is a better approach if the program you wish to suspend has a GUI: suspending it completely would result in an apparently dead window on the screen (and make you unpopular with users).
Personally, I would revisit the question of why you wish to suspend the process in the first place. By trying to do this, you are suggesting a timing dependency of your program with another, and you might be better off with another strategy (eg start the other program when you are ready for it to work to completion).
|