Hi,
I need some help with PostMessage or SendNotifyMessage.
In the past I was using SendMessage, but because this waits untill it is processed by the target application it was not what I wanted.
Now I want to change the way I send/post it.
I've read that both PostMessage and SendNotifyMessage do not wait.
Here is a part of the code i'm using to test/get it working with SendNotifyMessage
And in the main of my app i do:
The error i get in "GetLastWin32Error is 1159, so ERROR_MESSAGE_SYNC_ONLY.
Am I using it wrong? and what can I do to fix it?
Thanks
I need some help with PostMessage or SendNotifyMessage.
In the past I was using SendMessage, but because this waits untill it is processed by the target application it was not what I wanted.
Now I want to change the way I send/post it.
I've read that both PostMessage and SendNotifyMessage do not wait.
Here is a part of the code i'm using to test/get it working with SendNotifyMessage
Code:
public class TestSendMessage {
[DllImport("user32.dll")]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32.dll", SetLastError = true)]
private static extern Boolean SendNotifyMessage(IntPtr hWnd, WndMsg Msg, IntPtr wParam, IntPtr lParam);
public static void sendTo() {
IntPtr objHandle = FindWindow(null, "testform")
if (!objHandle.Equals(IntPtr.Zero)) {
bool blnOK = SendNotifyMessage(objHandle, WndMsg.WM_COPYDATA, IntPtr.Zero, IntPtr.Zero);
if (!blnOK) {
int intErrorCode = Marshal.GetLastWin32Error();
}
}
}
}
And in the main of my app i do:
Code:
while (true) {
TestSendMessage.sendTo();
System.Threading.Thread.Sleep(2000);
}
The error i get in "GetLastWin32Error is 1159, so ERROR_MESSAGE_SYNC_ONLY.
Am I using it wrong? and what can I do to fix it?
Thanks