public static void SendMsgString(IntPtr hWndDest, string sScript ) { COPYDATASTRUCT oCDS = new COPYDATASTRUCT(); oCDS.cbData = (sScript.Length + 1) * 2; oCDS.lpData = LocalAlloc(0x40, oCDS.cbData); Marshal.Copy(sScript.ToCharArray(), 0, oCDS.lpData, sScript.Length); oCDS.dwData = 1; IntPtr lParam = AllocHGlobal(oCDS.cbData); Marshal.StructureToPtr(oCDS,lParam,false); SendMessage(hWndDest,WM_COPYDATA,IntPtr.Zero,lParam); LocalFree(oCDS.lpData); FreeHGlobal(lParam); }