Click here to Skip to main content
15,880,405 members
Articles / Programming Languages / C#

DDEApp, DDE Based Inter-process Communication (C#, C++)

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
10 Jun 2012MIT5 min read 29.9K   9   9
DDEApp, DDE Based Inter-process Communication (C#, C++)

This article discusses an inter-process communication protocol dedicated for sharing data and perform remote function call between applications.

Introduction

DDE Application (DDEApp) is a Dynamic Data Exchange (DDE) based inter-process communication protocol created to exchange data and perform functions call between applications.

Back in 2009, when I was still programming in Borland C++ Builder, I needed to find a solution to call function remotely between two applications. We had decided to make use of DDE for this purpose. Using VCL control in Borland, we managed to get DDE up within few days. However, soon we realized that the existing DDE protocol was not able to fully meet our requirement.

About DDEApp

DDEApp is a command line inter-process communication protocol implemented based on DDE. It contains a client and host class named as below.

 C#Borland C++
DDEApp ServerDDEAppServerMDDEApp_Server
DDEApp ClientDDEAppClientMDDEApp_Client

An overview of the classes is shown as below. DDEApp Client is designed to handle multiple clients.

Actual inter-process communication took place in DDE Server and Client class.

Image 1

DDEApp Features

Hide Low Level Settings from User

There are several parameters that need to be set correctly in DDE Server and Client class before two processes can "talk" to each other using DDE. Client needs to know the server's setting upfront. User must figure out these settings either from code or documentation to establish DDE connection with Server.

DDEApp hides all DDE related parameters from user. Users who use DDEApp did not need any knowledge of DDE. A standard sets of setting will be used for all DDEApp Server and Client instances. This means that all DDEApp Servers and Clients can communicate with each others.

Support Multiple Clients and Servers

DDEApp Client and Server is designed to handle multiple clients and servers. A DDEApp Client can connect to multiple servers while a DDEApp Server is able to handle respond from multiple clients.

Image 2

The diagram above shows that both Client A and C are connecting to more than 1 server while Server B have 3 clients connected to it. Besides, Server B also can be configured as Client to communicate with Server C at the same time being a server.

DDEApp Protocol

To ensure the correct message is passed between selected server and client, DDEApp implemented a command line message protocol which contains information of sender and receiver as below:

<Source> <Dest> <Commands>

  • Source: Sender application's EXE name
  • Dest: Receiver application's EXE name
  • Commands: DDEApp commands

When using DDEApp class, we do not need to remember the command format. Encode and decode of the commands are done internally by DDEApp Client and Server class.

A DDEApp Server is visible as virtual class to client application with list of registered functions and variables. Registered functions are accessible using FunctionCall() in DDEApp Client whereas registered variable are accessible from VariableRead() and VariableWrite() in DDEApp Client.

Cross platform (C++ / C#)

As an inter-process communication protocol, DDEApp allows application build from different platform (e.g. Borland Builder 5, Borland Builder 6, Visual C#) to communicate with each other. This is useful for mid to large scale projects when code conversion from one platform to another is time consuming and expensive.

Standard Functions

DDEApp Server included a list of common functions to remotely control the server's application.

  • Help
  • HideMainForm
  • RestoreWindow
  • MinimizeWindow
  • BringToFront
  • SetWindowPosition

Function Lists

The "Help" function shown above is an internal function created to return list of registered functions and variables from DDEApp Server. With these features, we are able to get the most updated functions and variables list which may change from version to version. This is much better than any external documentation.

The image below shows a list of functions and variables in DDEApp Client terminal returned from a DDEApp enabled server application.

Image 3

Function Call with Error Reporting

All function calls from DDEApp Client to DDEApp Server are made via FunctionCall(). Client will receive execution status upon completion of the functions. FunctionCall() is available in both synchronous and asynchronous version.

The image below shows an example of DDEApp function call which returns without error. Besides, it also shows additional information sent from DDEApp Server when executing function.

Image 4

This is another example that shows failed function call which returned an error message.

Image 5

Variable Read / Write

Variable read or write are done in a similar way as function call except that variable are either read and write or just read only. Read or write to variable is a synchronous call using VariableRead() and VariableWrite().

Connect / Disconnect / Shut Down

DDEApp Client can be connected or disconnected from DDEApp Server when required using function Connect() and Disconnect(). Server will get notified when a client is connected or disconnected.

Besides, the client can request server to shut down using ShutDownServer() function. An OnClientShutdownQuery event will be raised at server application. Server has full authority to decide whether to proceed to shutdown itself.

Online / Offline

Online() and Offline() are two functions dedicated for DDEApp Server to enable or disable DDEApp protocol. When server is offline, none of the clients are allowed to connect to the server. Any client that was connected earlier will received a OnLinkClosed event.

DEMO and Tutorial

NOTE

DDE Application and C++ Library is compiled using Borland C++ Builder.

If you were not able to run the executable file, please get the re-distributed library from below:

  • Borland C++ Builder 6 libraries. Download
  • Borland Developer Studio 2006 libraries. Download

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Technical Lead
Malaysia Malaysia
Official Page: www.codearteng.com

Comments and Discussions

 
QuestionRegisterFunction SetFunctionCallback Pin
Member 102047027-Apr-22 7:19
Member 102047027-Apr-22 7:19 
AnswerRe: RegisterFunction SetFunctionCallback Pin
Code Artist9-Apr-22 1:02
professionalCode Artist9-Apr-22 1:02 
GeneralRe: RegisterFunction SetFunctionCallback Pin
Member 1020470211-Apr-22 4:48
Member 1020470211-Apr-22 4:48 
GeneralRe: RegisterFunction SetFunctionCallback Pin
Code Artist12-Apr-22 1:10
professionalCode Artist12-Apr-22 1:10 
Questiondownload links don't work Pin
Member 768450613-Jul-15 0:16
Member 768450613-Jul-15 0:16 
AnswerRe: download links don't work Pin
Code Artist13-Jul-15 3:14
professionalCode Artist13-Jul-15 3:14 
GeneralRe: download links don't work Pin
Vasiliy Maslov30-Mar-21 0:03
Vasiliy Maslov30-Mar-21 0:03 
GeneralRe: download links don't work Pin
Code Artist30-Mar-21 2:43
professionalCode Artist30-Mar-21 2:43 
QuestionCan't access dropbox at work Pin
Sandeep Datta29-May-13 21:19
Sandeep Datta29-May-13 21:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.