首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

关于Winform调用外部exe,并设置exe初始位置的有关问题

2013-09-06 
关于Winform调用外部exe,并设置exe初始位置的问题[DllImport(User32.dll, EntryPoint FindWindow)]p

关于Winform调用外部exe,并设置exe初始位置的问题



[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); 
        }



winform exe
[解决办法]
从Process开始运行,到创建一个窗口,会有一些延迟。

System.Diagnostics.Process p = System.Diagnostics.Process.Start("E:\\form\\form1");
p.WaitForInputIdel();   //<-- 加这行
MoveWindow(p.MainWindowHandle, 800, 500, this.Width, this.Height, true);

热点排行