views:

401

answers:

2

I shell out an application from my VB6 app. I would then like to close it. How can I pull this off?

+1  A: 

Check this out:

End an Application that was Started by the Shell Function

dommer
AngryHacker
+2  A: 

Here is Karl Peterson's VB6 method for closing applications. As you request, this asks nicely - sending WM_CLOSE rather than using TerminateProcess. Note that it sends the message to all of the top-level windows belonging to the process, there could be more than one.

I haven't tried this, but in my experience Karl Peterson's code always rates five stars out of a possible five!

EDIT: Please note this is an edited version of the original answer, and now links to the latest version of Karl's code. If anyone has questions about this, Karl is still active on the VB6 newsgroup but I don't think he hangs out on Stack Overflow.

MarkJ