Solved

Exit a vb6 apps when a calling it apps closes

Posted on 2016-11-03
15
52 Views
Last Modified: 2016-11-03
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)
0
Comment
Question by:rayluvs
  • 7
  • 5
  • 3
15 Comments
 
LVL 4

Expert Comment

by:Chris Watson
ID: 41872268
Are you wanting to close the child application when the parent application closes, or close the parent application when the child application closes?
0
 

Author Comment

by:rayluvs
ID: 41872367
Exactly!
0
 
LVL 46

Assisted Solution

by:Martin Liss
Martin Liss earned 250 total points
ID: 41872463
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:rayluvs
ID: 41872478
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
 
LVL 46

Accepted Solution

by:
Martin Liss earned 250 total points
ID: 41872505
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
 

Author Comment

by:rayluvs
ID: 41872532
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
 
LVL 46

Assisted Solution

by:Martin Liss
Martin Liss earned 250 total points
ID: 41872585
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
 

Author Comment

by:rayluvs
ID: 41872600
Yes that makes sense, we go there, thanx!
0
 

Author Comment

by:rayluvs
ID: 41872604
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
 
LVL 4

Assisted Solution

by:Chris Watson
Chris Watson earned 250 total points
ID: 41872623
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
 

Author Comment

by:rayluvs
ID: 41872637
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
 
LVL 46

Expert Comment

by:Martin Liss
ID: 41872640
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
 
LVL 4

Assisted Solution

by:Chris Watson
Chris Watson earned 250 total points
ID: 41872683
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
 

Author Comment

by:rayluvs
ID: 41872705
Yes, sorry guys, didn't read correct the first.  We can do that, kill the apps from the parent.

Thanx!
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 41872718
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question