.IntroductionSometimes, we need to communicate with other applications, such as send and receive strings. In VB6, we can easily use the SendMessage function to send a wmdatacopy message, because we can define lparam as Any. Digital Box 31-Jul-Jul-07 18:34Send to same instance work fine but when sent to another instance, they cannot get the message. (may be dotnet have protected each applications memory space)any ways to put the string into some global memory space?here's my code:on the form i have 3 textbox1. Change name of this instance2.
Set target window name3. Thanks for your quick reply.but it would be more flexible if it can let 2 completely different programs to communicate with each other.therefore i tried to create a new process instead of a new formand i have successfully send integer the each other, so it seems got the right windowby replacingDim i As IntPtr = Marshal.StringToHGlobalUni(msg)withDim i As IntPtr = new IntPtr(100)even when sending text they sometimes got the garbage text and sometimes my personal firewall say access to protected memory, so i guess there's difficulties for dotnet to send string to another programJason Lam. The reason why you can not send data is you got a wrong window handle. If you can get the correct window handle, and send message to the correct handle, the program will surely catch the data you just send.be noticed that I used findwindow function in the demo project to get the window handle, the 'lpWindowName' parameter is very important, it's the parameter to let you to specify the aim window's caption.
If u do want to use the same form to catch the message, you need to change the destination window's caption at run-time, then use findwindow to get the handle, and send message to this window.or you can try to create 2 projects, 1 is send, another is receive, they are totally independent programs, and the data can be exchanged.-Marshal.StringToHGlobalUni(msg) will copy the contents to memory and return the memory address, so you may not change it otherwise you will get a wrong address and if you use this wrong address to read data, of coz it will be rubbish.