Click to See Complete Forum and Search --> : Getting a handle to another process


mspivey
January 8th, 2000, 10:33 AM
How do I get a handle to another process (a DOS box) so I can then close it down? I have a VB app that will restart the PC if certain criteria occurs. I am trying to get the handle to this DOS box to then close either by TerminateProcess or sending WM_CLOSE via SendMessage.

Any ideas.

Thanks,
Mike

January 8th, 2000, 05:29 PM
Sorry I don't know any universal methods to do this, but if you know exactly what window you need to close, you can use Spy++ program which comes with Visual Studio. Run it, click on 'Find Window' button, on appeared window click and drag 'Finder Tool' icon over your DOS window. You'll see Window Class parameter for your DOS window. You can use it with PostMessage API with WM_CLOSE constant to kill that DOS Window.
Vlad

wilton
January 8th, 2000, 06:24 PM
A way to do this automatically from a program would be to import the necessary function for parsing window titles. Things about a dos window is they usually only have the path in the title. Check out MSDN for the needed functions. I think that the codeguru site might also have the needed information.