I work on Delphi 6 and try to make communication between 2 process with windows message. One of the process (Process1) is not a window so I use the MsgHandler to create an invisible windows. I create 2 handlers using AddMsgHandler and wait for messages from the other process (Process2).
Process2 send 2 different kinds of message, one is is a PostMessage with lparam containing an integer value (it works) but the second is a SendMessage with lparam containing TCopyDataStruct and here is the issue, Porcess1 never receive the messages.
Code: Select all
procedure SendMessage(AReceiveStringList : TStringList);
var
LReceivedMsg : string;
LCopyDataStruct : TCopyDataStruct;
begin
if AReceiveStringList .Count > 0 then
begin
LReceivedMsg := ReceiveStringList.Strings[0];
LCopyDataStruct .dwData := hdr_ComAxe;
LCopyDataStruct .cbData := Length(LReceivedMsg ) + 1;
LCopyDataStruct .lpData := PChar(LReceivedMsg );
if (Pos('EB',ReceivedMsg) > 0) then
begin
Windows.SendMessage(Self.FCommunicationHandle, WM_COPYDATA, 0, Integer(@LCopyDataStruct ));
end;
end;
Code: Select all
constructor TSequencesLoader.Create(ALogger : TLogger);
begin
inherited Create();
// Allocation des MsgHandler pour la réception des réponses d'A_Com_Ax
madTools.AddMsgHandler(ManageCopyDataMessage, WM_COPYDATA);
madTools.AddMsgHandler(ManageAckNackMessage, WM_ACKNACK);
end;
Is someone have an idea of what's happen?
Thanks.