Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Commenication between application

Posted on 1997-06-21
14
190 Views
Last Modified: 2010-04-04
Hi!

I want to commenicate between to programs. I want to have a program that answears "questions" from other programs. And I want a dll where a have the functions that phass a string or something to the program, and got a answear back. Hope somebody understand what I meen and helps. Thanks !

Chr
0
Comment
Question by:chrb
  • 8
  • 6
14 Comments
 
LVL 2

Accepted Solution

by:
icampbe1 earned 200 total points
ID: 1337379
There are quite a few ways to attack your problem.  If you want a 'quick' solution to get things going and refine it later then try this:

Get a message ID for your application(s).  Use this to comminicate between them:
   {Each program makes this same call to get the same ID}
   MessID := RegisterWindowMessage('My Special Message' );
   {Now, send to the required app (or brodcast)}
  PostMessage( App.handle, MessID, wp, lp );

  {the receiving app of course must receive the message and process it}

  A somewhat primitive way to send data around is to do so througha file.
 The file name(s) is agreed upon between the apps.

Like I said, this will get you 'on the air' while you impelement other methods.

Cheer,
Ian C.

0
 

Author Comment

by:chrb
ID: 1337380
Hi!

Could you please give me an example?

And would this handle a lot of messages between the program. My plan was to make a "server" for a virtual filesystem, where the client send a filename and got the real path back.

Chr
0
 
LVL 2

Expert Comment

by:icampbe1
ID: 1337381
Do you want to communicate across platforms?  ie Are you using Win95, and are there some 16 bit apps that must participate?

0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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:chrb
ID: 1337382
There would only be 32 bits, but they need to work at NT 4.0 too. I would make a DLL which other programs can use to communicate.
0
 
LVL 2

Expert Comment

by:icampbe1
ID: 1337383
I was initially going to suggest using a broadcast type message  etc... but this is better.  
Use the WM_COPYDATA message facility.  It will permit you to send messages to and from all processes (including 16 bit participants).  The structure contains a pointer to the data you are trying to share  and that pointer gets corrected for you if you cross platforms.

When you send a WM_COPYDATA message, you specify the recipient, and the sender (as wParam) as well as the structure (as lParam).  The structure looks like:
TYPE
   PcopyData = ^TCopyData;
   TCopyData = Packed Record
      dwData: DWORD;
      cbData: DWORD;
      lpData: Pointer;
   END;

So in the code it looks like:

VAR  Buff: TCopyData;
....
SendMessage( Target, WM_COPYDATA, Handle, Longint(@buff) );

When the apps start up would be a good time for them to exchange handles.  You could use a RegisterWindowMessage to get a unique ID, to a broadcast, and go from there.

This is a very good solution for what you are doing.

Cheers,
Ian C.

0
 

Author Comment

by:chrb
ID: 1337384
Increase to 190
0
 

Author Comment

by:chrb
ID: 1337385
Increased to 200
0
 

Author Comment

by:chrb
ID: 1337386
May I have an full working example now? Where to programs finds the handles and communicate.

Thanks!

Chr
0
 
LVL 2

Expert Comment

by:icampbe1
ID: 1337387
I am gone from the city (and my desk) till Friday Aug. 8th.  If you can wait till then, I will be happy to help you.  

Until then, the Application object has a handle property  you can use for communicating  - Application.Handle  <--- like this.

Cheers,
Ian C.
0
 

Author Comment

by:chrb
ID: 1337388
Could you give me an example now please ?

Thank you!
0
 
LVL 2

Expert Comment

by:icampbe1
ID: 1337389
I am glad you commented, I received an E-mail of your comment and that reminded me to look here.  

The message facility that I described earlier is reasonably well documented in the Delphi docs.  However, there are many ways to do this.  It would help if I had an idea of your experience level.  

I will also suggest a very powerful communication facility you can use called 'memory mapped files'.  With this, all of the participating programs can communicate via a common memory space.  The nature and the length of the program messages is entirely up to you.  

If you have a little time, it would be well worth your time to read about windows messages and memory mapped files.

Also, are writing all of the programs that will communicate? If so, you can make better use of whatever facility you choose right from the start.  I'm sure you realize that it is somewhat difficult for me to write the entire communication faciltiy for you.  I am hoping to steer you in the right direction.  If you need addition help after looking at both messaging and mapped files, I'll gladly help you.

Ian C.
0
 

Author Comment

by:chrb
ID: 1337390
Where can I find info about memory mapped files ?

I have got some years experience with TP, and almost one with Delphi.
0
 
LVL 2

Expert Comment

by:icampbe1
ID: 1337391
There is a very good book you can read which will show you about messages, mapped files, and much more.  

It is called the Delphi 2 Developer's Guide by Sams Publishing, ISBN: 0-672-30914-9.  I don't know if there is a Delphi 3 Guide yet but it doesn't matter.  All that you need is in this book.  It is $59.9 US and I believe that it is worth it.   It contains many examples of programs and difficult tasks that you encounter every day (much like your need).

I hope this is helping you.

Ian C.

0
 

Author Comment

by:chrb
ID: 1337392
I am sorry that I havn't graded you yet, I had one more question and I forgot it all. Sorry.

Chr
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Downloading email attachments 2 79
When i run adoquery my application freezes 26 179
Dev express lookupcombo 3 35
Twebbrowser add css to the header 3 28
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

828 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