集成C应用程序与WPF

本文关键字:WPF 应用程序 集成 | 更新日期: 2023-09-27 18:13:49

我被要求开发一个Windows应用程序,作为现有C应用程序的包装器。C应用程序由命令行控制。我想知道是否可以使用WPF作为此应用程序的GUI ?

集成C应用程序与WPF

当你的应用程序是一个控制台应用程序时,试试这个:

Process process=Process.Start(new ProcessStartInfo("Your.exe") {
    RedirectStandardInput = true,
    RedirectStandardOutput = true,    
    RedirectStandardError = true,
    UseShellExecute = false,
});
process.StandardInput.WriteLine("Your command");
var yourAnswer=process.StandardOutput.ReadLine();

这只是一个简单的例子,也许还有其他的解决方案来与你的应用程序沟通。好的搜索关键字是"IPC":-)