Processing custom windows message

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I have created a custom windows message and using SendNotifyMessage
(user32.dll) the message is sent (broadcasted).

I send the message as follows:
[DllImport("user32.dll", CharSet=CharSet.Auto)]
private static extern int SendNotifyMessage(IntPtr hwnd, IntPtr
wMsg,
IntPtr wParam,
IntPtr lParam);

SendNotifyMessage((IntPtr)0xffff, RegisterWindowMessage("somestring"),
Marshal.StringToHGlobalAuto("a message"),
Marshal.StringToHGlobalAuto("another message"));

I am receiving the message in another c# app as follows:

protected override void
WndProc(ref System.Windows.Forms.Message m)
{
if(m.Msg == RegisterWindowMessage("somestring"))
{

string s = Marshal.PtrToStringAuto(m.WParam);
}

else
{
base.WndProc(ref m);
}
}


The message is received in WndProc without any problems, however the
lparam and wparam properties (when marshalled) have empty strings.

It seems that the pointer created in the sendmessage call points to a
section in memory that when in the WndProc call points to nothing at
all.

When I inspect the memory location in the app that sends the message,
the messages are in fact there.

Does anyone have any advice or suggestions as to what might be wrong?

Thanks in advance.

Ryan Fransen
.



Relevant Pages

  • Re: iperf: performance regression (was b44 driver problem?)
    ... this is the first such app and really, and even for this app: ... circumstances use up the whole CPU on high-res timers. ... One is receiving data and the other ... If the spinning thread doesn't yield, ...
    (Linux-Kernel)
  • Re: Safest way to pass data between web apps?
    ... Or simply a generated/custom session ID. ... form which you post to the receiving application, ... >> data across to the other app and the "receiving" app can extract only ... >> - Paul Glavich ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Windows wont shut down
    ... Can you show me how to implement WndProc? ... When windows is shutting down, ... > app cancels the request to shut down, then it will halt the shutdown. ... >> system tray, windows doesn't close down and there's no error messages. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: app to app thread notification
    ... In registering a message, use a GUID as part of the message, e.g., ... PostThreadMessage can only work if there are no user-visible GUI components in the thread. ... Of course you will need the thread ID from the receiving app, ...
    (microsoft.public.vc.mfc)
  • Re: passing COleDateTime with lparam in postmessage
    ... I did have a struct in the header file but was trying ... > instances of the same app. ... > COleDateTime on the receiving end. ... There is no need to broadcast the ...
    (microsoft.public.vc.mfc)