Hello Stack overflow users! I have a problem making the program and I ask a question,,
Here are two console programs. ( I Make to Visual Studio 2017 C++ )
The first Program name is "A", second Program name is "B". Both programs A and B are console programs.
- Program "A" checks whether program "B" is running normally.
- If program "B" is terminated, program "B" is forcibly executed by program "A".
I had a problem in number 2.. Program "B" must be run as an external program separate from program "A". But now,, program "B" runs in program "A" console prompt..
Please tell me How to run as a separate program.. Thx.
my code is :
int main() //Program A
{
STARTUPINFO si = { sizeof(si) };
PROCESS_INFORMATION pi;
ShowWindow(::GetConsoleWindow(), SW_SHOW);
while (true)
{
if (CheckRef == true)
{
//ShowWindow(::GetConsoleWindow(), SW_HIDE);
std::cout << " " << getStateProcess(ProcessName) << std::endl;
if (getStateProcess(ProcessName) == 0) // Check to Program "B" is Running?
{
// Program "B" is not Running. Started Program "B"
CreateProcess(NULL, (LPSTR)ProcessPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
Sleep(10);
}
}
else
{
ShowWindow(::GetConsoleWindow(), SW_SHOW);
system("cls");
std::cout << "Start Ref Settring. . ." << std::endl;
SetRef();
}
Sleep(500);
}
return 0;
}`