简体   繁体   English

c ++ MFC使用进度条执行三个连续的进程

[英]c++ MFC execute three consecutive processes with a progress bar

Thank you for reading my post. 感谢您阅读我的帖子。 Here is my problem: 这是我的问题:

I need to install (run) three programs one after the other: P1, P2 and P3. 我需要一个接一个地安装(运行)三个程序:P1,P2和P3。

If P1 is not installed properly, P2 installation will fail. 如果未正确安装P1,则P2安装将失败。

And if P1 and P2 are not installed properly, P3 installation will fail. 如果未正确安装P1和P2,则P3安装将失败。

In addition to this, I need a dialog box which displays a progress bar and shows the progress of the installation: 除此之外,我需要一个对话框,其中显示一个进度条并显示安装进度:

  • after P1 is installed, the progress bar will be set to 1/3 full, 安装P1后,进度条将设置为1/3满,
  • after P2 is installed, the progress bar will be set to 2/3 full, 安装P2后,进度条将设置为2/3满,
  • after P3 is installed, the progress bar will be set to 3/3 full. 安装P3后,进度条将设置为3/3满。

I am using C++ and MFC. 我正在使用C ++和MFC。

I am asking myself whether I should: 我问自己是否应该:

  • create one process for P1, one process for P2 and one process for P3 using the "CreateProcess()" function ( http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx ). 使用“ CreateProcess()”函数为P1创建一个进程,为P2创建一个进程,为P3创建一个进程( http://msdn.microsoft.com/zh-cn/library/windows/desktop/ms682425%28v=vs。 85%29.aspx )。 I have already tried this option but I am having a hard time making sure P1 installation is finished before P2 installation starts and P1 and P2 are installed before P3 installation starts and to synchronize the progress bar with these installations... 我已经尝试过此选项,但是要确保在开始P2安装之前完成P1安装以及在开始P3安装之前先安装P1和P2以及将进度条与这些安装同步是很困难的。
  • having X threads: one main thread which basically shows the progress bar, one (or several threads) to install P1, P2 and P3. 具有X个线程:一个主要显示进度条的主线程,一个(或几个线程)用于安装P1,P2和P3。

So I have two problems to solve: 所以我有两个问题要解决:

  • launching three installations one after the other, 陆续推出三套装置,
  • having a dialog box which shows the progress of the installation. 有一个对话框,显示安装进度。

Can you tell me how you would do that? 你能告诉我你会怎么做吗?

Another question I'm asking myself is whether a thread can be used to launch a command like "msiexec"? 我要问自己的另一个问题是,是否可以使用线程来启动“ msiexec”之类的命令?

Best regards. 最好的祝福。

In the dialog box, after creating Pn (n = 1, 2, 3), start a timer which periodically calls GetExitCodeProcess until the exit code is not STILL_ACTIVE (259); 在对话框中,创建Pn(n = 1、2、3)后,启动一个计时器,该计时器定期调用GetExitCodeProcess,直到退出代码不是STILL_ACTIVE (259); verify that the exit code is not an error, update the progress bar and start the next process. 确认退出代码不是错误,更新进度条并开始下一个过程。

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

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