我在 ac# 应用程序和 delphi 应用程序之间的 Windows 消息有问题。
我用c#到c#和delphi到delphi做了一些例子,但我不能用c#到delphi
这是我相关的 C# 应用程序,它是 WM 发件人代码
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);
这是我相关的 delphi 应用程序,它是 WM 接收器代码
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;
提前致谢。