This demo demonstrates how to send / receive WM_COPYDATA messages between a collection of C++ and C# programs.
Traditionally WM_COPYDATA was used to send a limited amount of data between processes on the same machine. It is still desirable to interoperate this way even with the rise of .NET. .NET Remoting is out of the scope of this demo. This demo is intended for people like myself that are dealing with legacy environments.
The demo consists of four programs and one DLL. Two programs are written in C++ (MS Version 5.0) and two are written in C# (using .NET 2003). A C++ exe and C# exe will send the structure shown below to a C++ and C# receiving program.
struct sTagData {//this is the structure that will be sent (copied) by the WM_COPYDATA private: char szTag[ciMaxTag]; char szData[ciMaxData]; }
The DLL was written in VC 5.0 and it wraps the WM_COPYDATA message.
Additionally, the DLL provides a uniform way of :-
HWND_BROADCAST the WM_COPYMESSAGE.
Unzip using the full paths to your C drive. The result should be the shown directory structure.
To use the demo, open folder build and click on all 4 executables. Click on the send buttons in the FROM apps and the message will appear in the TO apps. Both FROM programs are document to show how to use the DLL�s interface. Likewise, both TO programs are documented in their WindowProc()�s to show how to receive the data.
These programs have only been tested on Windows XP.
Philip McGahan is the sole creator of this demo. No part of it has been plagiarized from other sources. Any party may use all or part of this demo with out credit or reference to Philip McGahan.
Lastly, it is only fair to tell my reader that I am very new at C#. I did try to use C# to build the DLL. But beyond never getting the data to come across with out junk at the end of the string. I was not comfortable with having to setup unsafe blocks. The whole thing just seemed clumsy. When or if I get better at C#, I will revisit this issue.
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||