使用的Process.Start C#的形式执行C ++的exe() [英] Execute C++ exe from C# form using Process.start()

查看:442
本文介绍了使用的Process.Start C#的形式执行C ++的exe()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个C#窗体应用程序,将允许我使用我以前所有的C ++从一个中央计划项目。

I'm trying to create a C# form app that will allow me to use all of my previous C++ programs from one central program.

我能打开与的Process.Start()的前男友,但它不能正确编译代码。

I'm able to open the exes with Process.Start(), however it does not compile the code correctly.

示例代码:

Process.Start("C:\\\Documents and Settings\\\dan\\\Desktop\\\test.exe");

这将打开控制台,并像它的运行,但它不喜欢,当我正常运行编译出来的C ++编辑器。是否有一个的StartInfo 变量,我需要设置以表明它是一个C ++程序或沿这条线的东西吗?

This will bring up the console and act like it's running, but it does not run like when I normally compile out of the C++ editor. Is there a startinfo variable I need to set to signify that it's a C++ program or something along that line?

此外,有没有以任何方式使用来执行C ++程序的Process.Start ,让我通过 ARGC 的argv

Also, is there any way to execute a C++ program using process.start that will allow me to pass it variables through the command line via argc and argv?

感谢

推荐答案

有一对夫妇只差异,当您使用的Process.Start你做对的时候,你只要直接执行该程序的方式。两者都可以通过使用的ProcessStartInfo 加以解决。

There are only a couple of differences when you use Process.Start the way you did vs. when you just execute the program directly. Both can be addressed by using ProcessStartInfo.


  1. 的的工作目录不会是相同的。将其设置为包含可执行以获得相同的行为的路径。

  2. 设置的 UseShellExecute 为true,因此Windows外壳程序来执行的过程。

  1. The WorkingDirectory will not be the same. Set this to the path containing the executable to get the same behavior.
  2. Set UseShellExecute to true, so the windows shell is used to execute the process.

至于添加命令行参数:你可以做到这一点通过的 ProcessStartInfo.Arguments 的。不应该有要求,由于它是一个C ++应用程序,不过之一。

As for adding command line arguments: You can do that via ProcessStartInfo.Arguments. There shouldn't be one required due to it being a C++ application, however.

这篇关于使用的Process.Start C#的形式执行C ++的exe()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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