[DllImport("User32.dll", EntryPoint = "FindWindow")]
        public extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
        [DllImport("user32.dll", SetLastError = true)]
        private static extern bool MoveWindow(IntPtr hwnd, int x, int y, int cx, int cy, bool repaint);
        private void button1_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process p = System.Diagnostics.Process.Start("E:\\form\\form1");
           
                       MoveWindow(p.MainWindowHandle, 800, 500, this.Width, this.Height, true); 
        }winformexe

解决方案 »

  1.   

    可以显示出form1窗体,但是不能设置他的初始位置。不知道为什么,movewindow方法也执行了,也没报错
      

  2.   

    从Process开始运行,到创建一个窗口,会有一些延迟。System.Diagnostics.Process p = System.Diagnostics.Process.Start("E:\\form\\form1");
    p.WaitForInputIdel();   //<-- 加这行
    MoveWindow(p.MainWindowHandle, 800, 500, this.Width, this.Height, true);
      

  3.   

    WaitForInputIdle();