Link to home
Start Free TrialLog in
Avatar of samuel999
samuel999

asked on

How to have one VB program make a request of another VB .exe program that is already running.

I know VB6 well, but not ActiveX, COM, etc.

I want to create two VB6 programs.  The first .exe program will run first, have a UI, and do some communication to the Internet and then wait idle.  The second .exe program will run later, and needs to request the first program to communicate with a certain website.  How can I reliably pass that request from program two to program one?

Do I use ActiveX?  Do I use COM?  For whatever simplest method you recommend, please provide sample VB6 code in program one and two.
Avatar of mkhaleelr
mkhaleelr

pls try winsock
Hi,

You can use a FLAG that will be "light-up" by the first program and will be monitor by the second program.
You can use a txt file or a ini file or to use a database file (like MsAccess) if you need more then a flag to shere with the two appliecations...

Good luck!
Avatar of samuel999

ASKER

Both .exe's will be running on the same machine.  Winsock is probably not the best way to communicate between two .exe's running on the SAME machine.  Anyone have a COM example?
try one of these :
1. use DDE technic
2. program 1 can use SENDMESSAGE Api to read sample text from any text box on form progran2 and take state
3. P1 write state in registery key & p2 read that value
4. P1 create file & P2 Read That File
5. P1 Work Like com server & p2 search for existence of com server
6. p1 write data in shared DB & p2 read from DB
etc

say for more ;)
ASKER CERTIFIED SOLUTION
Avatar of EDDYKT
EDDYKT
Flag of Canada 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
Hi,

I stiil think my comment above is the best way to tranfer/share data between two application (especially after reading your last comment... )

Have fun.
>>I stiil think my comment above is the best way to tranfer/share data between two application (especially after reading your last comment... )

No offense, just a question, how often do you think he should scan the ini file to see the changes?
Well, I know you are very good programer and real expert - I can not compete you, I am just a beginer...
So, there is "no offence",  but read the question - its the matter of how often the secound program will "...communicate with a certain website..."
From the question above "...The first .exe program will run first, have a UI, and do some communication to the Internet and then wait idle.  The second .exe program will run later, and needs to request the first program to communicate with a certain website..."
Well as I see it, he said that the first program will do something and wait idle and then the second program will run later (!) and do somthing....
So, again he can check the flag every time he thinks he need it....

Secondly: if he will use MsAccess there is no problem, both application can keep the database open and the value of the flag can be, lets say, the value of a yes/no checkbox... or whatever...

What do you think my friend?
Before this question starts a fight....

I don't think using a database will work.  When program #2 wants program#1 to communicate with a certain website, it needs to happen within a second or two after program #2 initiates the request.  So, program #1 would have to check the database every second.  Too often.

DDE is not forward compatible, so that's out...
SMESSAGE is a possibility...

Really want something that allows an instant response from program #1, and also an API I can give to others if they want to write a program that requests program #1 to do something.
I don't think there is a fight. It is just discussion.

In Window's world, it is better to program as event driven instead of polling.

It is just my opinion, sorry for interruption.

8->
I'm with EDDYKT - there is no fight.

Maybe you can use "SendKey" to a controll of the other program and use the event "on change"?

Anyhow good luck to all of you!
Try to write service for handling both exe

http://www.smsoft.ru/en/ntservice.htm
If you want to share your first program's interface with other developers, then it would be logical to use an ActiveX EXE as suggested by EDDYKT.  The other methods may work, but they are a little too "quirky" to seriously consider sharing with other developers.

The only other approach I might suggest would be to pass a command string to the first program, so instead of having it sitting idle, you launch a new instance of it with a command string, and when it finishes it's task, exits.  Assuming it's getting information from an internet site, you can save the information somewhere so the calling program can read it.