Sending message to another process
-
I need to send WM_COPYATA to another process from a C# program. Is there a C# method (maybe a class) equivalent to the Win32 API SendMessage(HWND h, ...) ?
-
-
Thanks, Satips, but in fact it didn't help me. I'm converting a working MFC program to C# and the only thing I stuck on is sending WM_COPYDATA message to another process, and the article doesn't say which method or class I should use (maybe I should use interop ?). Thanks anyway.
-
Thanks, Satips, but in fact it didn't help me. I'm converting a working MFC program to C# and the only thing I stuck on is sending WM_COPYDATA message to another process, and the article doesn't say which method or class I should use (maybe I should use interop ?). Thanks anyway.
You could simply use P/Invoke SendMessage using this[^] p/invoke declaration. To get the window handle of the other process, you can use
Process.GetProcess
to get the process object for the other process and then use theMainWindowHandle
property to get the window handle. You would also need to use the actual value of WM_COPYDATA (0x004A), as that enum doesn't exist in C#.Regards Senthil [MVP - Visual C#] _____________________________ My Blog | My Articles | My Flickr | WinMacro
-
You could simply use P/Invoke SendMessage using this[^] p/invoke declaration. To get the window handle of the other process, you can use
Process.GetProcess
to get the process object for the other process and then use theMainWindowHandle
property to get the window handle. You would also need to use the actual value of WM_COPYDATA (0x004A), as that enum doesn't exist in C#.Regards Senthil [MVP - Visual C#] _____________________________ My Blog | My Articles | My Flickr | WinMacro