Indy TCPサーバースレッドから(Uni)DDEサーバーに接続しようとしています。通常のアプリケーションから接続でき、PLC変数を取得/設定できます。
しかし、Indyスレッドから(Execute(AThread:TIdPeerThread)イベントから)同じコマンドを使用すると、SetLinkコマンドが失敗しました。
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;
おそらく、DDEはWindowsメッセージを使用しているのでしょうか、それとも他のものがスレッドセーフではないのか、スレッドのレベルでキャッチできないのでしょうか。
これについての情報をありがとう:dd