I'm having a trouble with Windows Messages between a c# app and delphi app.
I did some examples with c# to c# and delphi to delphi but I cannot c# to delphi
Here is my related c# app which is WM sender codes
void Game1_Exiting(object sender, EventArgs e)
{
Process[] Processes = Process.GetProcesses();
foreach(Process p in Processes)
if(p.ProcessName == Statics.MainAppProcessName)
SendMessage(p.MainWindowHandle, WM_TOOTHUI, IntPtr.Zero, IntPtr.Zero);
}
private const int WM_TOOTHUI = 0xAAAA;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int SendMessage(IntPtr hwnd, [MarshalAs(UnmanagedType.U4)] int Msg, IntPtr wParam, IntPtr lParam);
Here is my related delphi app which is WM reciever codes
const
WM_TOOTHUI = 43690;
type
private
MsgHandlerHWND : HWND;
procedure WndMethod(var Msg: TMessage);
procedure TForm1.WndMethod(var Msg: TMessage);
begin
if Msg.Msg = WM_TOOTHUI then
begin
Caption := 'Message Recieved';
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
MsgHandlerHWND := AllocateHWnd(WndMethod);
end;
Thanks in advance.