delphivcldde

Is it possible to enumerate all available DDE servers with `TDdeClientConv` class?


I was curious about all the running DDE servers, tried TDdeClientConv class but got confused with it (may be just didn't figured out how) and finally rolled my own low-level (normally applications should use DDEML abstraction layer) "client":

procedure TForm6.FormClick(Sender: TObject);
begin
  { initiate DDE conversation with all top-level windows }
  SendMessage(
    HWND_BROADCAST,
    WM_DDE_INITIATE,
    Handle,
    MakeLParam(
      0,        // all services
      0         // all topics
    )
  );
end;

procedure TForm6.WMDDE_Ack(var Message: TWMDDE_Ack);
begin
  { this message handler receives acknowledgements }
  { and prints service-topic pairs to console }
  Writeln('"' + GetAtom(Message.App) + '"', #9, '"' + GetAtom(Message.Topic) + '"');
end;

Question: is it possible to do the same with TDdeClientConv class, that is, initiate a DDE conversation with all available services and receive multiple acknowledgements? Or TDdeClientConv merely represents client endpoint of DDE conversation and thus my scenario is out of the scope?


Solution

  • TDdeClientConv does not use any window messages, it uses the Dynamic Data Exchange Management Library (DDEML) instead. TDdeClientConv can connect only to a single server that implements a specified Service and/or Topic, as it establishes its connection using the DDEML DdeConnect() function:

    Establishes a conversation with a server application that supports the specified service name and topic name pair. If more than one such server exists, the system selects only one.

    DDEML's DdeConnectList() function, on the other hand, can establish a conversation with multiple servers supporting a given Service and/or Topic.

    Establishes a conversation with all server applications that support the specified service name and topic name pair. An application can also use this function to obtain a list of conversation handles by passing the function an existing conversation handle. The Dynamic Data Exchange Management Library removes the handles of any terminated conversations from the conversation list. The resulting conversation list contains the handles of all currently established conversations that support the specified service name and topic name.

    You can enumerate that list using the DdeQueryNextServer() and DdeQueryConvInfo() functions.