Boolean SendData(IntPtr targetHWnd, String toSend, Messages id) { Win32.CopyDataStruct aCDS = new Win32.CopyDataStruct(); aCDS.ID = (Int32)id; aCDS.Data = toSend; if (toSend != null) aCDS.Length = aCDS.Data.Length + 1; IntPtr aRetVal = Win32.SendMessage(targetHWnd, Win32.WM_COPYDATA, IntPtr.Zero, ref aCDS); return (aRetVal != IntPtr.Zero); } class Win32 { public static readonly uint WM_COPYDATA = 0x004a; [StructLayout(LayoutKind.Sequential)] public struct CopyDataStruct { public Int32 ID; public int Length; public string Data; } [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] public static extern IntPtr SendMessage( IntPtr windowHandle, uint Msg, IntPtr wParam, ref Win32.CopyDataStruct lParam ); }Based in parts on http://www.codeproject.com/KB/cs/skypecontrolapicsharp.aspx.
*======================================================================================== * Set up a handler to receive data posted with WM_COPYDATA *======================================================================================== #define WM_COPYDATA 0x004A Public goCOPYDATA goCOPYDATA = CreateObject("COPYDATA_Handler") ? "handle: ", Transform(goCOPYDATA.hWND,"@0") Define Class COPYDATA_Handler as Form Procedure Init BindEvent( This.hWND, WM_COPYDATA, This, "WndProc" ) EndProc Function WndProc Lparameters tnHwnd, tnMsg, tnWParam, tnLParam Local lcStruct, lnIdentifier, lcData lcStruct = Sys(2600,m.tnLParam,12) lnIdentifier = FromInt(Left(m.lcStruct,4)) lcData = Sys(2600,FromInt(Right(m.lcStruct,4)),FromInt(SubStr(m.lcStruct,5,4))) ? lnIdentifier, lcData Return 99 EndDefineIn this case you would need to pass goCOPYDATA.hwnd to the .NET program that wants to send data. If you have a unique window title, the .NET application can use FindWindow to search for the window handle. Unlike with sockets both applications have to run on the same machine.