Using system;
Using system. drawing;
Using system. collections;
Using system. componentmodel;
Using system. Windows. forms;
Using system. Data;
Using system. runtime. interopservices;
Namespace winformsendmsg
{
Partial class form1: system. Windows. Forms. Form
{
Private system. Windows. Forms. textbox textbox1;
Private system. Windows. Forms. Button button1;
Const int wm_copydata = 0x004a;
Public form1 ()
{
Initializecomponent ();
}
[Dllimport ("user32.dll", entrypoint = "sendmessage")]
Private Static extern int sendmessage (
Int hwnd, // handle to destination window
Int MSG, // message
Int wparam, // first Message Parameter
Ref copydatastruct lparam // second Message Parameter
);
[Dllimport ("user32.dll", entrypoint = "findwindow")]
Private Static extern int findwindow (string lpclassname, string
Lpwindowname );
Private void button#click (Object sender, system. eventargs E)
{
Int window_handler = findwindow (null, @ "receiver form ");
If (window_handler = 0)
{
}
Else
{
Byte [] Sarr = system. Text. encoding. Default. getbytes (this. textbox1.text );
Int Len = Sarr. length;
Copydatastruct CDs;
CDs. dwdata = (intptr) 100;
CDs. lpdata = This. textbox1.text;
CDs. cbdata = Len + 1;
Sendmessage (window_handler, wm_copydata, 0, ref CDs );
}
}
}
Public struct copydatastruct
{
Public intptr dwdata;
Public int cbdata;
[Financialas (unmanagedtype. lpstr)]
Public String lpdata;
}
}
Using system;
Using system. drawing;
Using system. collections;
Using system. componentmodel;
Using system. Windows. forms;
Using system. Data;
Using system. runtime. interopservices;
Namespace windowsformgetmsg
{
Partial class form1: system. Windows. Forms. Form
{
Private system. Windows. Forms. textbox textbox1;
Const int wm_copydata = 0x004a;
Public form1 ()
{
Initializecomponent ();
}
Protected override void defwndproc (Ref system. Windows. Forms. Message m)
{
Switch (M. msg)
{
Case wm_copydata:
Copydatastruct mystr = new copydatastruct ();
Type mytype = mystr. GetType ();
Mystr = (copydatastruct) M. getlparam (mytype );
This. textbox1.text = mystr. lpdata;
Break;
Default:
Base. defwndproc (ref m );
Break;
}
}
}
Public struct copydatastruct
{
Public intptr dwdata;
Public int cbdata;
[Financialas (unmanagedtype. lpstr)]
Public String lpdata;
}
}
/Files/njnudt/exe.rar