Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 启动C++;Visual Studio 2010中.NET项目中的项目_C#_C++_Visual Studio 2010 - Fatal编程技术网

C# 启动C++;Visual Studio 2010中.NET项目中的项目

C# 启动C++;Visual Studio 2010中.NET项目中的项目,c#,c++,visual-studio-2010,C#,C++,Visual Studio 2010,我有以下问题: 我有两个项目,项目游戏包含一个用C++语言编写的游戏,使用SDL库。Project Launcher是一个C#.NET项目,它提供了一个界面,在启动Project游戏之前可以从中选择选项 我的问题是 A) 如何从Project Launcher中启动Project游戏? B) 如何将参数从项目启动器传递到项目游戏 我还没有找到一个明确的解决办法,只是在这里和那里耳语。对于这些参数,显而易见的是,只需用参数调用.exe并在C++中读取它们,但我想知道是否有一种更为清洁的方法来构建这

我有以下问题:

我有两个项目,项目游戏包含一个用C++语言编写的游戏,使用SDL库。Project Launcher是一个C#.NET项目,它提供了一个界面,在启动Project游戏之前可以从中选择选项

我的问题是 A) 如何从Project Launcher中启动Project游戏? B) 如何将参数从项目启动器传递到项目游戏


我还没有找到一个明确的解决办法,只是在这里和那里耳语。对于这些参数,显而易见的是,只需用参数调用.exe并在C++中读取它们,但我想知道是否有一种更为清洁的方法来构建这个.NET。任何帮助都将不胜感激。如果我找到了解决方案,我会把它贴在这里。

我现在没有IDE,所以我不确定,但我记得类似这样的东西应该可以解决这个问题

ProcessStartInfo proc = new ProcessStartInfo();
//Add the arguments
proc.Arguments = args; 
//Set the path to execute
proc.FileName = gamePath;
proc.WindowStyle = ProcessWindowStyle.Maximized;

Process.Start(proc);
编辑:
我的错,我没看到你在寻找不使用传递参数的方法。我留下回复只是为了参考其他人!:)

NET framework包含一个名为Process的类,它包含在Diagnostics命名空间中。您应该使用System.Diagnostics包含命名空间,然后启动应用程序,如下所示:

using System.Diagnostics;

// Prepare the process to run
ProcessStartInfo start = new ProcessStartInfo();
// Enter in the command line arguments, everything you would enter after the executable name itself
start.Arguments = "readme.txt"; 
// Enter the executable to run, including the complete path
start.FileName = "notepad";
// Do you want to show a console window?
start.WindowStyle = ProcessWindowStyle.Hidden;
start.CreateNoWindow = true;

//Is it maximized?
start.WindowStyle = ProcessWindowStyle.Maximized;

// Run the external process & wait for it to finish
using (Process proc = Process.Start(start))
{
     proc.WaitForExit();

     // Retrieve the app's exit code
     exitCode = proc.ExitCode;
}