【问题标题】:Call C++ programs from C# /WPF从 C# /WPF 调用 C++ 程序
【发布时间】:2011-03-03 13:31:43
【问题描述】:

谁能给我一个完整的例子,说明如何从 C# 运行已编译的 C++ 程序(可执行文件)。

提前致谢。

【问题讨论】:

标签: c# c++ wpf


【解决方案1】:

我觉得你想要的是这样的:

Process myProcess = new Process();

try
{
    myProcess.StartInfo.UseShellExecute = false;
    // You can start any process; HelloWorld is a do-nothing example.
    myProcess.StartInfo.FileName = "C:\\HelloWorld.exe";
    myProcess.StartInfo.CreateNoWindow = true;
    myProcess.Start();
    // This code assumes the process you are starting will terminate itself. 
    // Given that is is started without a window so you cannot terminate it 
    // on the desktop, it must terminate itself or you can do it programmatically
    // from this application using the Kill method.
}
catch (Exception e)
{
    Console.WriteLine(e.Message);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多