I found “Delphi Inter Process Communication (IPC) using SendMessage” with Google.
Here’s a piece of the code from Sender to send a message for Receiver :
procedure TfrmClient.FormCreate(Sender: TObject);
begin
MyMsg := RegisterWindowMessage('MyMessage');
ServerApplicationHandle := FindWindow('TApplication', 'Project1');
end;
The problem is my receiver have random caption name. So how can I send a message to receiver? Any idea?
My Sender is a DLL and my receiver is Exe.
One obvious solution is for the EXE to give the DLL the handle to a window that it should send messages to. The EXE will call a function in the DLL, so that’s the perfect time to provide a window handle. Remove all the guesswork. (For that matter, the EXE could just give the DLL the address of a function to call and skip messages altogether.)
Another solution is to broadcast the message. Use the special window handle
HWND_BROADCASTwhen you callSendMessageand the message will go to all the top-level windows in the system. Only other windows that have registered the same message ID will do anything when they receive that message; the others should simply and safely ignore it.