I try to connect to (Uni)DDE server from an Indy TCP Server thread. From normal application I can connect, and can get/set any PLC variables.
But when I use same command from Indy thread (from Execute(AThread: TIdPeerThread) event), the SetLink command failed.
procedure ReadDDE(AppPath, Service, Topic, Cmd: string; out Eredmeny : string; out HibaSzint : string);
var
DDE: TDDEClientConv;
pc : PChar;
begin
Eredmeny := '';
HibaSzint := '';
DDE := TDDEClientConv.Create(nil);
try
DDE.ConnectMode := ddeAutomatic;
DDE.ServiceApplication := AppPath;
DDE.FormatChars := False;
HibaSzint := 'SetLink';
if DDE.SetLink(Service, Topic) then begin
HibaSzint := '';
pc := DDE.RequestData(PChar(Cmd));
Eredmeny := StrPas(pc);
StrDispose(pc);
end;
finally
DDE.Free;
end;
end;
Maybe the DDE is using Windows messages, or other things are not threadsafe, or not catchable in the thread's level?
Thanks for any info about this: dd