Here is my code.
using namespace std;
string myStrng;
string myStrng2;
string myDirectory;
string myDirectory2;
int main()
{
int myFinder;
int myFinder2;
basic_string<TCHAR> myDirectory;
cout << "Type in the default path to your server files.\n\n";
getline(cin, myDirectory);
Sleep (800);
cout << "\n\n";
cout << "So the server files are in " << myDirectory << " Is that correct? y/n ";
getline(cin, myStrng2);
myDirectory2 = myDirectory + "\\MatchAgent\\MatchAgent.exe";
myDirectory = myDirectory + "\\MatchServer\\MatchServer.exe";
if (myStrng == "y" || myStrng == "Y")
{
cout << "\n\n";
cout << "O.k, Keeper will now keep an eye on your MatchServer + MatchAgent. " << endl;
}
loop1:
myFinder = PostMessage (FindWindow(0, "MatchServer - MatchServer1"), NULL, 0, 0);
myFinder2 = PostMessage(FindWindow(0, "MatchAgent - MatchAgent1"), NULL, 0, 0);
if (myFinder == false)
{
cout << "MatchServer Crashed!\n";
cout << "Now opening MatchServer!\n";
ShellExecute(NULL, "open", myDirectory.c_str(), NULL, NULL, SW_SHOW);
Sleep (6000);
cout << "Now opening MatchAgent!\n\n";
ShellExecute(NULL, "open", myDirectory2.c_str(), NULL, NULL, SW_SHOW);
Sleep (2000);
goto loop1;
}
if (myFinder == true)
{
goto loop1;
}
It compiles fine, runs smooth. However, my program thinks that "MatchServer - MatchServer1" && "MatchAgent - MatchAgent1" is always closed, and probably attempting to open it again. (These 2 programs do not allow more than 1 of itself to open.)
I know I can use the PID, but this is just a beta until I decide to put in a .ini reader/writer.
P.S: WinExec() didn't work so well, so I reverted back to ShellExecute() for now.

New Topic/Question
Reply




MultiQuote




|