简体   繁体   English

如何在我的 c++ 程序中使用和启动 exe 文件?

[英]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.

相关问题 如何在C ++应用程序中的exe文件中打开文件 - How can I open a file inside of an exe inside of my c++ app 如何在我的主程序c ++中使用我自己制作的Array头文件? - How can I use my own made Array header file in my main program c++? 如何使用C ++ exe启动jar文件? - How to launch a jar file with c++ exe? 我如何获取和使用头文件<graphics.h>在我的 C++ 程序中? - How I can get and use the header file <graphics.h> in my C++ program? 获取Visual Studio项目名称(或exe文件名)以在C ++程序中使用它 - Get Visual Studio project name (or exe file name ) to use it inside a C++ program 实现一个系统,我的程序可以在 c++ 中构建一个 exe 文件 - Implementing a system where my program can build an exe file in c++ 如何通过C ++运行.exe文件? - how can I run a .exe file through C++? 如何使用C ++编译项目,以便在硬盘上创建项目的.dll文件,以便以后将其与其他程序一起使用? - How can I compile my project in C++ so it will create on my hard disk a .dll file of my project to use it later with another program? 如何在我的c ++程序中将GDAL库用作可选库? - How can I use GDAL library as optional in my c++ program? 如何转换我的堆排序程序以使用 C++ 标准容器(例如 std::vector)? - How can I convert my heap sort program to use C++ standard containers (for example std::vector)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM