Hi all,
I posted a question on Stackoverflow and I’m struggling to find an answer.
https://stackoverflow.com/q/65508292/4700011
Anyone here reckon they could have a bash at it?
Thanks in advance.

I’m a bit confused: Which is your code, the sender or recipient?
I am able to send data between two C# applications I have created, using the code samples you provided.

In your StackOverflow it seems as if you are both sending and receiving, and say that the receiiving end does not pick up the WM_COPYDATA message, but in your other post, it seems as if you need to only send a message to a third-party application InSpec.

The only other thing I can think of is if the other application is running with elevated permissions, Windows will block COPYDATA messages from less-privileged applications.

Is the 3rd party application InSpec a desktop app with a UI (Window)?
You can use Spy++ which should be included in Visual Studio to check the windows messages being sent to an application. You’re not debugging the 3rd party app. It’s running like normal, and Spy++ lets you snoop on the messages being sent to it.

I just took your interop definitions and your Run method and dropped them into a solution with two separate WinForms applications, one to call SendMessage and one to override wndProc.

I set the solution to multiple startup projects, ran them both in debug, and clicked a button on the “send” form that calls your Run method.
The form with the overridden wndProc looks like this:
The ouput written by the WndProc is:

So, I can only assume that you’re using the wrong hWnd if your wndproc isn’t receiving the message.

source