Link to home
Start Free TrialLog in
Avatar of cmrobertson
cmrobertsonFlag for United States of America

asked on

Detect WM_CLOSE event in vb6

I need to know when a particular process has shut down so I can shut down my running vb6 program
Avatar of nffvrxqgrcfqvvc
nffvrxqgrcfqvvc

You can do this by using OpenProcess() API with the SYNCHRONIZE (0x00100000L) access right. After which you than create an event with CreateEvent() you can then wait on the process handle by using WaitForMultipleObjects().

If the process in question is already running before your process then the above applies. You will also need the Process ID you can either use CreateToolHelp32() to find the PID by name or FindWindow() and GetWindowThreadProcessId() to find the PID by title.

However if you  launc the application from your exe than you can use the Shell() command which will return you the process id.
Avatar of cmrobertson

ASKER

I haven't abandoned the question, sorry i got busy and havent had a chance to try this - I am going to work on it in the next day or so and wanted to leave open in case i need a follow up question
Sure no problem. The only question I have is how you are opening the application.

Do you want to open the application from within your program.
Are you trying to do this on a program that is already running before your program starts.

The above will help when creating an example but a couple of things have to be altered depending on which reflects how you launch the program.
I more than likely will be shelling to the application from inside my vb project
ASKER CERTIFIED SOLUTION
Avatar of nffvrxqgrcfqvvc
nffvrxqgrcfqvvc

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Excellent, exactly what I was looking for - Thanks!