chrb
asked on
Commenication between application
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do you want to communicate across platforms? ie Are you using Win95, and are there some 16 bit apps that must participate?
ASKER
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.
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.
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.
ASKER
Increase to 190
ASKER
Increased to 200
ASKER
May I have an full working example now? Where to programs finds the handles and communicate.
Thanks!
Chr
Thanks!
Chr
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.
Until then, the Application object has a handle property you can use for communicating - Application.Handle <--- like this.
Cheers,
Ian C.
ASKER
Could you give me an example now please ?
Thank you!
Thank you!
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.
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.
ASKER
Where can I find info about memory mapped files ?
I have got some years experience with TP, and almost one with Delphi.
I have got some years experience with TP, and almost one with Delphi.
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.
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.
ASKER
I am sorry that I havn't graded you yet, I had one more question and I forgot it all. Sorry.
Chr
Chr
ASKER
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