2011-03-03 124 views
1

有人能指出我如何從C#運行編譯C++程序(可執行文件)的完整示例。從C#/ WPF調用C++程序

在此先感謝。

+1

你只是要啓動的.exe文件,好像有人從命令提示符下運行它? – Karmastan 2011-03-03 13:33:32

+0

[Process.Start()](http://msdn.microsoft.com/en-us/library/53ezey2s.aspx) – CheeZe5 2011-03-03 13:35:45

+0

http://msdn.microsoft.com/en-us/library/system.diagnostics。 processstartinfo.aspx – Christian 2011-03-03 13:33:43

回答

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); 
}