Note that there are some explanatory texts on larger screens.

plurals
  1. POBroadcast Windows HWND_BROADCAST message
    text
    copied!<p>I am working in an application in this application I shall wait for some event in application 1 and when this event happen I shall sendmessage to application 2 which will perform something.</p> <p>First API declaration</p> <pre><code>private const int HWND_BROADCAST = 0xffff; [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] public static extern int RegisterWindowMessage(string lpString); [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] static extern bool SendNotifyMessage(int hWnd, int Msg, int wParam, int lParam); </code></pre> <p>Application 1 Code</p> <pre><code>private string msgstr = "MYMESSAGE"; public int msg = RegisterWindowMessage(msgstr); if (msg == 0) { MessageBox.Show(Marshal.GetLastWin32Error().ToString()); } //SendNotifyMessage(HWND_BROADCAST, msg, 4848484, 8484865); SendNotifyMessage(HWND_BROADCAST, msg, 0, 0); MessageBox.Show(Marshal.GetLastWin32Error().ToString()); </code></pre> <p>Application 2 Code</p> <pre><code> static readonly int msg = RegisterWindowMessage("MYMESSAGE"); protected override void WndProc(ref Message m) { if (m.Msg == msg) { MessageBox.Show(m.Msg.ToString() + " = from wndproc"); } base.WndProc(ref m); } </code></pre> <p>Will somebody point out what is problem with this code. I suspect there is problem in SendNotifyMessage </p> <blockquote> <p>lparam and wparam parameters</p> </blockquote> <p><strong>Will somebody suggest me any other alternative to achieve this behaviour!</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload