简体   繁体   English

如何使用C ++代码运行MFC应用程序exe文件?

[英]How to run a MFC application exe file with c++ code?

I am new to MFC and C++. 我是MFC和C ++的新手。 A MFC application was given to me, ssentially what I am trying to achieve is to run this MFC application from my standard C++ code in another project that will be build into a library. 给了我一个MFC应用程序,基本上,我想要实现的目标是从我的标准C ++代码在另一个要构建到库中的项目中运行此MFC应用程序。 This c++ code perform some simple if else logic where it decides if the MFC application should run or not. 此c ++代码执行一些简单的if逻辑,它决定MFC应用程序是否应该运行。 Could someone explain how I could achieve this? 有人可以解释我如何实现这一目标吗?

Assume: MFCApplication.h and MFCApplication.cpp is in project one. 假定:MFCApplication.h和MFCApplication.cpp在项目1中。

Assume: My project (project 2) involves 假设:我的项目(项目2)涉及

DoWork.cpp with body DoWork.cpp与身体

if(some_logic)
{
MFCApplication x;
x.run();
.
.
.
x.terminate();
}

The answer is the same for any program, not just an MFC program. 答案对任何程序都是一样的,而不仅仅是MFC程序。 To run any application your program should call the CreateProcess API with the full path and filename of the exe file you wish to run. 要运行任何应用程序,您的程序应使用您希望运行的exe文件的完整路径和文件名调用CreateProcess API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM