Link to home
Start Free TrialLog in
Avatar of John Account
John Account

asked on

One exe controls another.

Hello Experts. I want to break down a large application into a few smaller different applications. So I would like to know if there's any way that I can control a form in one exe from the actions of a form in another exe--like at the click of a button, etc.? Many kind thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of SweatCoder
SweatCoder
Flag of United States of America image

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
Avatar of michaeldade
michaeldade

Unless you are just trying to get one exe to launch another or kill another exe then I dont think this is possible. Is your large application an MDI application? One ridiculous solution is to communicate via files but this is very ridiculous. Another solution is to use the process input and output streams to read and write between processes. I have done somehting simple that used these in Java but am not sure about vb.

Generally the appraoch used to break an application up is to define COM components for the various 'bits' of you application.  These DLL files are then referenced by the main EXE and it can call functions, subs, set properties, etc. in the 'exposed' classes.

By splitting your code up there are various advantages to do with working in a team and re-use of code, deployment of upgrades, plus a host of others.

The downside (based on your description) is that you want the 'smaller' apps to also run separately from the 'parent' app?  DLL's won't do that, although you could create COM EXE's to try and cover both sides of the coin.

Have a look under MSDN - there's various stuff on how to create a COM application.  Bit general for here.
At best the only thing you can do is transfer text and even that will be cumbersome. Even the biggest applications exist in a single process, look at word, visual studio etc, these are huge, I think you should take a look at your program design/interface.
Avatar of Mike Tomlinson
Another possiblity is to use sockets to communicate between your applications via the Winsock control.  You can define specific ports for each application to listen/send on...or have the main app act as a server and the sub programs connect to it.

Then you can define your own messages to send between them to act as events that trigger things in the apps.

~IM
Avatar of John Account

ASKER

Hmmmmnnnn...SweatCoder, sounds like you have the right idea. But now I'm wondering if it would be better to use the registry as you suggested, or an ini file to write & read to.  If, as you suggested, it would be best to use the registry as the solution, I'll increase the points to 500 if you can provide some sample code to write & read from the registry a value (for Yes or No), else I'll have to do it using an ini file, since I don't know how to do this with the registry.  Or I'll split the 500 points with anyone who can provide that sample code first. Many kind thanks in advance.
Hello JohnLucio
You can use DDE (Dynamic Data Exchange) which is a way to communicate between two controls in two different EXEs and trigger events in both apps.

This way you could save some overheading in your computer caused by frequently checking the registery or an ini file.
Hmmmmmnnnn...iHadi, thanks for the post! I'm researching and trying to figure out how to use DDE (Dynamic Data Exchange) to do this. Could you post some sample code for me, please?--if it's not too much to ask for! Many kind thanks in advance!!
Mmmmmmmnnnn...that DDE (Dynamic Data Exchange) solution looks quite demanding. I don't even see how that could cause less stress on the server than reading/writing to the registry or ini file. Nonetheless, no one seems to want to help with sample code for the registry solution or the DDE.  So, unless someone can help soon, I'm going to have to use an ini file. Many kind thanks in advance to you all.
Share Data Between Apps Without COM
http://www.thescarms.com/vbasic/PassString.asp
SweatCoder's post was accepted as the solution, but I'm going with using an ini instead, as I don't know how to do this with the Registry.  Although I don't have the time to implement Erick37's solution, I was really impressed with it that I feel he should get some points for sharing this. Erick37, please come here for your points:  https://www.experts-exchange.com/questions/21226762/Points-for-Erick37.html

Many kind thanks to you all,
John
John: I think the registry option will be MUCH easier and almost certainly faster in terms of performance. Here's how you do it:

To write a registry value:
SaveSetting "YourApplicationName", "YourSectionName", "YourSpecificItemName", "YourValueYouWantSaved"

To retrieve a registry value:
ReadThis = GetSetting("YourApplicationName", "YourSectionName", "YourSpecificItemName")

"SaveSetting" and "GetSetting" are both built-in VB functions. No dll's to call or declares to make, they're just built in.

Good luck.

Wow, thanks, SweatCoder--that's much better than a damn ini file!  I'm surprised it was so easy!!  There are some points for you at: https://www.experts-exchange.com/questions/21226837/Points-for-SweatCoder.html