[英]How can I use and launch an exe file inside my c++ program?
I want to use an.exe file inside my c++ program.我想在我的 c++ 程序中使用一个 .exe 文件。 I reviewed and checked these functions (system - ShellExecute - CreateProcess) to achieve this goal, but I found them useless because I need the output of that.exe file inside my program for further processes.
我查看并检查了这些函数(系统 - ShellExecute - CreateProcess)以实现此目标,但我发现它们无用,因为我需要在我的程序中使用 that.exe 文件的 output 以进行进一步处理。
CreateProcess can be used to pipe the output from the created program back to the creator. CreateProcess 可用于将 pipe 和 output 从创建的程序返回给创建者。 MSDN even has sample code to do exactly this: Creating a Child Process with Redirected Input and Output
MSDN 甚至有示例代码可以做到这一点: Creating a Child Process with Redirected Input and Output
I think you do want CreatProcess
.我认为您确实想要
CreatProcess
。 You can get the STDIN / STDOUT: http://msdn.microsoft.com/en-us/library/ms682499%28v=vs.85%29.aspx您可以获得标准输入/标准输出: http://msdn.microsoft.com/en-us/library/ms682499%28v=vs.85%29.aspx
you should use the "Process.standardOutput" to read the result of an.exe.您应该使用“Process.standardOutput”来读取 an.exe 的结果。
Here is the link on MSDN, there is plenty of explainations:这是MSDN上的链接,有很多解释:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput(v=vs.71).aspx http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput(v=vs.71).aspx
You could use one of those functions to execute your file and have it write the output to another file.您可以使用其中一个函数来执行您的文件并将 output 写入另一个文件。 Then you just have to read that into your program.
然后你只需要把它读入你的程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.