Exit a vb6 apps when a calling it apps closes

Hi,

We have an apps that calls another vb6 apps passing data for processing.  Is there a way for vb6 apps to detect if the calling apps closes or no more in memory? (that way we can close the apps)
rayluvsAsked:
Who is Participating?
 
Martin LissConnect With a Mentor Older than dirtCommented:
The only other thing I can think of is for the calling app to kill the called app. I'm sure you can find code to do that.
0
 
Chris WatsonSoftware DeveloperCommented:
Are you wanting to close the child application when the parent application closes, or close the parent application when the child application closes?
0
 
rayluvsAuthor Commented:
Exactly!
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
Martin LissConnect With a Mentor Older than dirtCommented:
When the calling app closes, have it create a text file with a specific name like "CallingAppClosed" and have the other app look for that file. If found then the called app should take appropriate action and then delete the file. You could do something similar with the Registry.
0
 
rayluvsAuthor Commented:
Yes, makes sense but that means that the apps has to be constantly searching that value in order to know that parent apps closed; thus, an another thing to consider into coding.  Is there another way, or maybe your way but to consider the apps not to be constantly looking at that value?

Please advice.
0
 
rayluvsAuthor Commented:
No, of course, that part is understood, it's that your recommendation requires the apps to be constantly reading the text file to see if the user exited from the parent apps, unless we didn't understand your recommendation.

Is what you recommended requires for the child apps to constantly read the text file?
0
 
Martin LissConnect With a Mentor Older than dirtCommented:
Looking for a flag in the Registry via API calls would probably be faster that looking for a file, but other than that I'm out of ideas,
0
 
rayluvsAuthor Commented:
Yes that makes sense, we go there, thanx!
0
 
rayluvsAuthor Commented:
No, wait, still have the same problem: the child apps will have to constantly look into the registry to see if the parent apps closed.
0
 
Chris WatsonConnect With a Mentor Software DeveloperCommented:
Another option might be to examine the list of the running processes. When the process representative of the parent application is no longer present, it's time for the child application to kill itself (once it has first properly grieved for the loss of its parent, of course).
0
 
rayluvsAuthor Commented:
Yes, that is also good; all are great as a matter of fact, it's the process of constantly looking to the location to see if the parent apps closed.

Don't know if we are transferring to you guys our concern .
0
 
Martin LissOlder than dirtCommented:
No, wait, still have the same problem: the child apps will have to constantly look into the registry to see if the parent apps closed.
Yes that's true.

You have only two options which are either having the called app constantly looking for an indicator that the calling app has closed which is time consuming, or have the calling app close the called app as I suggested in post ID: 41872505.
0
 
Chris WatsonConnect With a Mentor Software DeveloperCommented:
If you've opened the child application in the parent application with the Shell method, which returns the child's PID, you can close the child application at will (say, before you exit the parent application) using that PID.

There's some example code to do just that at the link below.

End an Application that was Started by the Shell Function - FreeVBcode.com

I think that's the sort of thing Martin had in mind in post 41872505, if you don't want to constantly poll in the child application to see if the parent application is still running.
0
 
rayluvsAuthor Commented:
Yes, sorry guys, didn't read correct the first.  We can do that, kill the apps from the parent.

Thanx!
0
 
Martin LissOlder than dirtCommented:
You're welcome and I'm glad I was able to help.

If you expand the “Full Biography” section of my profile you'll find links to some articles I've written that may interest you.

Marty - Microsoft MVP 2009 to 2016
              Experts Exchange MVE 2015
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2015
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.