在WPF应用程序中执行exe. [英] executing an exe within an WPF application.

查看:153
本文介绍了在WPF应用程序中执行exe.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在wpf应用程序中执行一个exe.我使用了以下代码:

I want to execute an exe within a wpf application. i have used the following code:

private void tabControl1_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
    if (tabControl1.SelectedIndex == 4)
    {
        Process p = new Process();
        p.StartInfo = new ProcessStartInfo("C:\\Program Files\\WordWeb\\wweb32.exe");
        // p.StartInfo = new ProcessStartInfo("C:\\Program Files\\WordWeb\\wweb32.exe", this.Arrange(rectangledict));
        //p.WaitForInputIdle();
        p.Start();
    }
}



我能够加载该exe.但是该exe将在其他窗口中打开.我希望该exe在同一窗口中运行.阅读一些博客后,我知道了实现亲子关系的过程.有人可以帮我做同样的事情吗?我正在使用VS 2008 SP1.



I am able to load the the exe. But the exe opens in a different window. I want the exe to run in the same window. After reading some blogs, I got to know to implement the parent child relationship. Can any body help me to do the same? I am using VS 2008 SP1.

推荐答案

如果要启动的应用程序是控制台应用程序,并且您希望将输出打印到表单中,则将帮助:如何重定向应用程序的标准输入/输出 [ ...
If the application you want to start is a Console application and you want the output to be printed into your form, then this will help: How to redirect Standard Input/Output of an application[^]

Otherwise, I don''t understand "I want the exe to run in the same window"...


您无法在您的应用程序窗口-从技术上讲,您可以,但前提是您的应用程序是操作系统的外壳程序(有点像Windows桌面实际上是以全屏模式运行的Windows资源管理器或运行的VM客户端完全不同的操作系统).
You can''t run another application in your app''s window - well, technically you can, but only if your application is a shell for the OS (kinda like the fact that the Windows desktop is actually Windows Explorer running in full-screen mode, or a VM client that runs a completely different OS).


如果您的主机应用程序只是写入控制台,请使用Olivier提供的解决方案.

如果没有,该怎么办?

您最好避免使用它,但是如果您真的想要它,那么我在过去的解决方案中已经解释了一些机会:

是否可以运行窗口表单另一个正在运行的窗口表单应用程序中的应用程序 [ http://msdn.microsoft.com/en-us/library/system. windows.forms.integration.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.windowsformshost.aspx [ ^ ],
http://nayyeri.net/host-windows-forms-controls-in-wpf [ ^ ].

同样,这取决于访客应用程序的工作方式.通常情况下,结果无法保证.

—SA
If your host application just writes to the console, please use solution provided by Olivier.

What if it does not?

You would better avoid it, but if you really want it, there are some opportunities I explained in my past Solution:

Is it possible to run a window form application from another running window form application[^].

With WPF, this is somewhat more difficult than with System.Windows.Forms. You may need to host a System.Windows.Forms.Control in your WPF application, see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.windowsformshost.aspx[^],
http://nayyeri.net/host-windows-forms-controls-in-wpf[^].

Again, it depends on how your guest application works. In the general case the result is not guaranteed.

—SA


这篇关于在WPF应用程序中执行exe.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆