是否可以在窗口窗体内运行外部.exe ?

本文关键字:运行 外部 exe 窗体 窗口 是否 | 更新日期: 2023-09-27 18:07:10

在这里,我试图运行一些基于窗口的应用程序(s)内的窗口形式的面板,并允许我尽量减少它里面。我可以在这个"notepad.exe"中运行和最小化,但不能在win应用程序中运行。

这里是我的代码供参考(只适用于记事本):

[DllImport("USER32.DLL")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);[DllImport("USER32.dll")]
private static extern bool MoveWindow(IntPtr hwnd, int x, int y, int cx, int cy, bool repaint);
Process process = Process.Start("someapp.exe");
process.WaitForInputIdle();
SetParent(process.MainWindowHandle, this.panel1.Handle);
MoveWindow(process.MainWindowHandle, 0, 0, this.Width - 90, this.Height, true);

请告诉我是否有可能实现以及如何实现?

是否可以在窗口窗体内运行外部.exe ?

好的,您需要做的就是替换

process.WaitForInputIdle();

Thread.Sleep(500); // Allow the process to open it's window

这是结果app1执行"For test app"多次,并将它们全部最小化