We help IT Professionals succeed at work.

Send Command to another Application

k4hvd77 asked
Last Modified: 2007-12-19
is there any way to send commands to another Application??I need something like  TCP/IP Client/Server to Send and Receive Some Commands from a Host Application.

Watch Question

perhaps more details about the target application you try to send commands to?

does it expect commands via TCP/IP? If yes, do you know what port it listen to, and also the list of commands (and perhaps parameters) that it is expecting?

or does it expect commands via SendMessage/PostMessage?

or perhaps via COM/CORBA/RMI?



Ok, I would Write a Server and a Client Application, The Client should be able to Send Commands to the Server Application, and both of them are running Local, I could use  a TCP/IP Server/Client (Indy TidTCPServer / TidTCP ) to Send and receive Commands but I'm looking for a Alternative.
Russell LibbySoftware Engineer, Advisory
Top Expert 2005


COM provides one alternative. The application server can register itself in the running object table, and clients can access the server that way. Event callbacks provide a means for the server to send info back to the clients (without the clients initiating the action). Provides a well-defined means of communication, but is not the lightest weight mechanism available.

Windows messages are another means of passing information back and forth (see WM_COPYDATA). Requires the client to be able to determine what the server's window handle is at runtime. Very light weigh mechanism.

DDE provides another (albeit antiquated) means of establishing a client / server communications channel as well. Simple to program against, lightweight communications.(not as light as messaging).

There are also a few other means of communications, such as mailslots, pipes, memory mapped files (used with events/mutexes for signalling). Kind of depends on what OS platform you wish to support with some of these, like names pipes begin NT based, etc.

In the end, it will probably boil down to which you are most comfortable with, and what types of requirements you have.

Hope this helps,
I would recommend you taking a look at Midware http://www.overbyte.be/frame_index.html

You can see how easily it is to create command handlers by looking at the demos given... it is really worth having a look :-)
go with TCP and Indy
that way you're not limited to the same machine or network
your app is immediately portable to another machine over internet
it's abit overhead using on the same machine but it's tolerable .. the tcp loopback isn't that slow :)

for larger apps I write services with RemObjects
it can't get easier than doing it with RemObjects :)
you're also not limited to the transport .. it can be a winmessage channel using WM_COPYDATA, mailslots, tcp, udp, email, direct dll ...
also enables compression, encryption .. ahh .. I should stop :) .. it's well worth the money
but depends on the target project

hello k4hvd77, as has already be mentioned, you can do this alot of different ways, but  it seems from your comments

Send and Receive Some Commands
Client should be able to Send Commands to the Server Application

you seem to only need a very simple way to send and receive "Commands"  I am guessing that could be an Integer or two?

A simple way to go would be to create a Memory Mapped File as the server starts, and this Mem mapped file would just have the servers Form's Handle in it (maybe some other Info, but you don't say), your client could just open this mem Mapped file and read the Server's form handle, and then use the standard   SendMessage( ) to get a couple of integers (wParam, and LParam) commands to the server, and the client will get an integer Responce command fron the server's Message Result, if more data was required to be transfered the already mentioned WM_COPYDATA could be used

if you are interested, I coild show some code


Midware uses TCP/IP!

Could you tell me more about DDE?? Code Examples could be helpfully.

I never worked with maped Files but I think I means that I cannot send the Command Directly to the Application??!!!

Please note, I just want to Send/Receive a String Commands.

Software Engineer, Advisory
Top Expert 2005
This one is on us!
(Get your first solution completely free - no credit card required)
Which version of Delphi you using?
Ya, so you do not want to use TCP/IP? Even stuff like DCOM internally uses TCP/IP.


I'm using Delphi 7, and I would not use TCP/IP if we could find another Solution.

Russell LibbySoftware Engineer, Advisory
Top Expert 2005


There is no reason you have to use tcp either, should you choose not to.
Win32 offers the following in regards to IPC communication:

Dynamic Data Exchange (DDE)
File Mapping
Windows Sockets

It should be noted that once you start crossing machine boundaries, then tcpip will be used as the underlying transport mechanism (for those IPC's that support cross-machine).

Re: file mapping ipc, take a look at the {delphi}\demos\ipc sample client and monitor application. Another good alternative should you choose to go that way.


Like what Russell says... as soon as your client and server are on different machines, you can't escape from TCP/IP.


I can not get it work!!

Russell LibbySoftware Engineer, Advisory
Top Expert 2005


Er.... perhaps a little more information to go on would be helpful. The code I gave you for dde was compiled, and tested, and rechecked; so I can only assume you are having issues with the client connecting to the server. Is this the case, or are you issues elswhere?

I can help you further if you provide something for me to go on.



I can compile Client and Server Application too, but if I changing Edit1 and 2 has no effects, so "Client and server are not Connected"!! I have changed the ServiceApplication too!

did you just copy the code ? you also need to set the events of the components :)


I have maked 2 projects saved them, opened the .dfm with Notepad, pasted the Form Code, saved it, opened the unit pasted the source code and compiled it! events are set! could you send the projects using emaill to int@titaniumserver.de



It works! but could you tell me how to do that Client use the Application path to Find and connect the server?
Russell LibbySoftware Engineer, Advisory
Top Expert 2005


The dde client side components are a little touchy (I'll explain in a minute) so first, it helps to build the server component first, so it is available.

By touchy I mean that if the Client converation is set to ddeAutomatic, it will attempt to launch the server (even in design mode) and if the server does not launch, it will clear out settings you have for DdeService/DdeTopic, as well as the DdeClientItem's DdeItem property. Its an annoying feature (bug), but one you should be aware of.

Once the server is built and available, the client conversation should have the following properties set:

(from delphi help)

DdeService - Use DdeService to specify the server application to link to. Typically, DdeService is the file name (with path, if necessary) of the DDE server application's main executable file without the .EXE extension. If the DDE server is a Delphi application, DdeService is the project name without the .DPR or .EXE extension. For example, to link to a TDdeServerConv component in PROJ1.DPR, set DdeService to PROJ1.

DdeTopic - Use DdeTopic to indicate the server-defined topic name of the DDE conversation. Typically, DdeTopic is a file name (with path, if necessary) used by the server application. If the DDE server is a Delphi application, by default DdeTopic is the caption of the form containing the linked component. If the DDE client is linked to a TDdeServerConv component, DdeTopic is the name of the server conversation component rather than the form caption.

And finally, there is the ServiceApplication. If the server is not in the "path", then this should be coded with the full path name of the file, minus the .exe extension.

(delphi help) Set ServiceApplication to the name of the server application. Typically, this is the same value as the DdeService property. Sometimes, however, DdeService is a value other than the DDE server application's executable file name. If the server application is not running when the TDdeClientConv tries to establish a DDE conversation, OpenLink uses the ServiceApplication property to launch the server.


A normal "real-world" design usage would be similar to the following:
1.) Build server side first
2.) Build client and debug with connect mode set to auto connect, and the path hardcoded into the serviceapplication property
3.) Once testing is complete, switch connect mode to manual, and use the OpenLink method to connect to the server.
4.) Figure out where (like the registry) to store the server location. If the server is already running, then the client can connect to it without this information.
5.) Code the client so it retrieves the server location, sets the serviceapplication property, then calls OpenLink.
6.) Retest to make sure it all works.

Hope this helps,

Just to follow solution :)

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.