appWin = IntPtr.Zero;
            exeName = sClientPath;
            // Start the remote application
            Process p = null;
            try
            {                // Start the process
                p = System.Diagnostics.Process.Start(this.exeName);                //p.WaitForExit();
                // Wait for process to be created and enter idle condition
                while (true)
                {                    if (p.WaitForInputIdle())
                        break;
                    Application.DoEvents();
                }                // Get the main handle
               
                    
                    appWin = p.MainWindowHandle;
                
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error");
            }            // Put it into this form
            SetParent(appWin, this.PanDilaer.Handle);            // Remove border and whatnot
            try
            {
                SetWindowLong(appWin, GWL_STYLE, WS_VISIBLE);
            }
            catch (Exception ex)
            { }            // Move the window to overlay it on this window
            MoveWindow(appWin, 0, 0, this.Width, this.Height, true);
        }
执行到SetWindowLong 时报错,但如果启动的是IE/写字板等的都没有事。对 PInvoke 函数“NewAgent!NewAgent.FrmMain: etWindowLong”的调用导致堆栈不对称。原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配。请检查 PInvoke 签名的调用约定和参数与非托管的目标签名是否匹配。