using (MemoryStream ms = GetMemoryStream()) { int hWnd = FindWindow(null, "Receive"); int dataSize = Convert.ToInt32(ms.Length); COPYDATASTRUCT cds; cds.dwData = 0; cds.lpData = Marshal.AllocCoTaskMem(dataSize); cds.cbData = dataSize; SendMessage(hWnd, WM_COPYDATA, 0, ref cds); Marshal.FreeCoTaskMem(cds.lpData); }