Here is my prototype:
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool PostMessage(int hhwnd, uint msg, IntPtr wparam, IntPtr lparam);
And here is how I'm using it:
PostMessage(HWND_BROADCAST, msg, Marshal.StringToHGlobalAuto("bob"), IntPtr.Zero);
In a different thread I can intercept this message, but when I try to get bob back using:
string str = Marshal.PtrToStringAuto(m.WParam); // where m = the Message object
I don't get bob in str.
I'm thinking this has got to be due to the fact that I referenced the "bob" string on one thread's stack and that reference has absolutely no meaning in a different thread's stack. But if that's the case, are these wparam and lparam pointers only really used for messages being passed in the same thread?
Edit* Correction: By thread I mean Process. This is a problem of passing a string between processes, not threads.