DDE Client
Version 1.3
Delphi component

 

Vincent LESAUVAGE
26, allée Darius Milhaud - 75019 PARIS - FRANCE
vincent@lesauvage.com
http://www.lesauvage.com

 

This is the component that Borland has not done correctly since Delphi 2.0, and that you can get finally: one DDE component which allow to connect to a data stream such as Excel or Reuter in order to get datas back in real.

DDE unit implements in 2 components (TDDEManager and TDDEClient) the Dynamic Data Exchange protocol for client side. You can use it with all versions of Delphi in 16 or 32 bits.

When 2 applications communicate together using DDE protocol, the one that gives datas is called server, and the other that receives datas is called client. Exchange process between 2 applications is called conversation. It is up to client application to start the conversation.

Datas have adresses (like people). An adress is divided in 3 parts (Service, Topic, Item): Service is the data source, generally the program name; Topic means a group of datas with the same properties; Item is a data in this group. When a client application wish to receive datas from a server application, it sends a request <Service, Topic> to the server which accept or refuse the conversation. Then the client ask a for a precise data with a request <Item>. Client can also ask to the server to notify the client each time the data has a new value.

A client can have many simultaneous conversations with many servers.

 

 

TDDEManager

TDDEManager = class(TComponent)
    Clients: TList;

    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;

    function PasteLink(var Service, Topic, Item: string): Boolean;
    function PasteLinkEx(cfFormat: Integer; var Service, Topic, Item: string): Boolean;
  end;

TClient = class
    DDEClient: TDDEClient;

    constructor Create(DDEC: TDDEClient);
  end;

TDDEManager component initializes the DDE protocol for the client application. A client application must have one and one only TDDEManager component. An error EDDEError is raised in case of problem.

 

TDDEClient

TDDEClient = class(TComponent)
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;

    function OpenConversation: Boolean;
    function CloseConversation: Boolean;
    function IsOpen: Boolean;

    function RequestData(Item: string; var DataSize: Integer): PChar;
    function AdviseData(Item: string): Boolean;
    function UnadviseData(Item: string): Boolean;
    function Execute(Item: string; Command: string): Boolean;
    function Poke(Item: string; pData: Pointer; DataLength: Integer): Boolean;
    function PokeEx(cfFormat: Integer; Item: string; pData: Pointer; DataLength: Integer): Boolean;

    property Service: string;
    property Topic: string;
    property Format: Integer;
    property TimeOut: Integer;
    property OnDataChange: TOnDataChange;
  end;

TOnDataChange = procedure(Item: string; const Value: PChar; ValueSize: Integer) of object;

The TDDEClient component is the conversation between the client and the server.

Once the conversation is open, you can get datas back, but set Format and TimeOut before all..