Make Program 'Talk' To Each Other

Hi! I would like to request a sample for the best way to make my VB program to 'talk' to each other. Like when the 'client' start it will 'inform' the 'main', etc.

I have found one example from the internet and I think its using DDE, but it needs to have textbox(control) on both the running program to run successfully. So I think there must be a better way.

FYI - I am running VB6

Thank you,
abokaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
DDE is the simplest solution. It's problem is poor documentation and its legacy status.
Surely having a text box control is not a problem?
GrahamSkanRetiredCommented:
Apologies to the Apostrophe Preservation Society for "It's" instead of "Its"
EDDYKTCommented:
>>but it needs to have textbox(control) on both the running program to run successfully.


You can set visbile to false
Expert Spotlight: Joe Anderson (DatabaseMX)

We’ve posted a new Expert Spotlight!  Joe Anderson (DatabaseMX) has been on Experts Exchange since 2006. Learn more about this database architect, guitar aficionado, and Microsoft MVP.

abokaAuthor Commented:
To EDDYKT -
Yep, have done that, but like my question - I want to find other better ways.

Thank you,
seanpageCommented:
Not necessarily a "better" way, but you could use TCP/IP to communicate over 127.0.0.1.   Have your server listen on a specific port for incoming connections, and receive data from your clients on a different port.  Then create a "ClientPacket" class, that includes a unique identifier for each packet, along with an "Instruction" code and a "Data" area... then when you send data to the server, it knows (a) what to process and (b) who to send a result back to.

Another very basic way is to open a hidden text file in the server path, and have the clients write to that file -- then use a timer to open it, read the data from it, and close it, every few seconds.   This isn't nearly as good a solve because it (a) means that server response is not instantaneous and (b) it increases disk activity on the server.

The "optimal" way to do it would be to use the Windows SendMessage API calls to send a Windows message to the server.

The two API calls you'll need are:

Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Boolean
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

The following message, found elsewhere on Experts Exchange, gives an example of using this method:
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_20694528.html

Good luck!

Sean

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
abokaAuthor Commented:
To seanpage -

I have looked at the link you provided and test the code, its working ok with the 'notepad'. But how could I 'trap' the message send to my program?

Do I need to have a textbox and a timer to constantly check if theres any message receive? I was hoping to find something without all that(control). Please advice with sample coding, thank you.


P/s - The TCP/IP thing is not suitable as its not a network program.

cheers,
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.