vendredi 7 août 2015

C++ idiot here - Check to see if an .exe is open

Basically before the program goes through all its code, I want something to check if a process called UrbanWarfare_pc.exe is running.

Here's an example of something I would like (please make your answer easy to understand, because I have no idea what I'm doing):

int checkProgramRunning() {
    // If statement to see if program running
    // If UrbanWarfare_pc.exe is running...
    return 0;
    // ...else...
    return 1;
}

int main(int nNumberofArgs, char* pszArgs[]) {
    if (checkProgramRunning == 1) {
        cout << "Please check that Urban Warfare is running and reopen the program.";
    system("PAUSE"); // <<< Yes I know, Windows only, I'll work on that later
    return 0;
    } else {
        // Run program stuff <3
    }
}

Of course, if you can think up a better way (that is easy to understand) then that's good too!

If you find its not, add comments to literally everything!

Aucun commentaire:

Enregistrer un commentaire