【发布时间】:2015-04-20 03:19:33
【问题描述】:
我有一个涉及打开应用程序的 C++ 程序(比如说calculator.exe)。我需要能够测试以确保此应用程序已打开。这是我的意思的一个例子。
#include <iostream.h>
int main()
{
system("start calculator");
if (something)
cout << "Calculator is running.\n";
cin.get();
return 0;
}
我需要为something 输入什么来测试计算器是否打开?
【问题讨论】:
-
使用实际的 API 调用而不是
system,你会得到一个很好的方便的句柄。 -
不要使用
iostream.h,使用iostream -
等一下!你打算用这些信息做什么。如果您测试应用程序正在运行,并且计划在知道它已打开的情况下执行某项操作,那么如果在您检查到您采取行动的时间之间应用程序关闭,您会怎么做?