Hi I have a console program A that launches another application B I created. Application B uses a lot of threads that uses while loops to wait for certain events or to know when to exit when a certain variable is set.

I would like program A to be able to kill application B but I am afraid if I use TerminateProcess some of the threads might not exit cleanly. Meaning the "return 0" line will not be reached. Can anybody confirm or deny that.

On a second note, usually in program B I request the user to press a key on the keyboard which causes all the threads to terminate. Is there a way for program A to send a virtual keystroke to application B. Thanks a lot for any answer.
Amish