【发布时间】:2010-01-29 08:39:57
【问题描述】:
- 我想使用 c# 代码在面板内的 winform .net 应用程序上运行 exe 文件
- 我可以使用
System.Diagnostics.ProcessStartInfo和Process p = Process.Start("notepad.exe");在单击按钮时运行 exe 文件,但是使用 c# 代码在面板中运行此记事本文件或任何其他 exe 文件的代码是什么? -
我想在面板中而不是在单独的窗口中运行应用程序。我运行了以下代码,但 exe 没有停留在屏幕上,也没有在面板中打开 请告诉我解决方案。
Process p = Process.Start("notepad.exe"); Thread.Sleep (600); // Allow the process to open it's window SetParent(p.MainWindowHandle, panel1.Handle); [DllImport("user32.dll")] static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
【问题讨论】:
-
@zoya,你看过我推荐的文章了吗?它显示了您正在寻找的示例。