It is absolutely clear. Your code can only return 0 or 1. You have your count of 0 and then either increment it once or not.
This is how can you enumerate the processes in your system:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682629%28v=vs.85%29.aspx[
^].
The top answer to this question explains how to get the processes main module file path, which gives you the most reliable criteria for "the same process":
http://stackoverflow.com/questions/1933113/c-windows-how-to-get-process-path-from-its-pid[
^].
Here is where you face a problem. You did not explain the criteria for "instance of particular process". All the processes are, by definition, different processes. If two processes have the same name, this is not a reliable criterion that this is "the same application", because two applications can have the same name. If you know the path name of the application files, you can say that all processes running this application are "the same", but if you, say, copy the application files in some other location and run it, you loose this criterion. If the process was yours, you could use some IPC to communicate between these processes to tell each other "I'm the same thing", but, in principle, even this could be duplicated by some unrelated application. Essentially, the system has no exact criterion of "the same application", and none of two processes are "the same".
—SA