It's not that easy, but if "TestDlg.exe" is your code, you should embed the recognition in this code instead of relying on some external process, develop in PHP or not. I'll explain why. You don't have enough information. You can request all processes being executed by the OS at some moment, but essentially, all you get is the set of some IDs (process and threads) and strings (names). This would not be 100% reliable, because you always have a chance that some unrelated processes have, say, identical names, just by accident.
In contrast, if you embed the recognition on your application, you can develop a very robust technique. The approach is not to detect anything, but to exist the second instance immediately and pass data (if any) to the first instance. I have a very robust solution and explain all the ideas in my past answers:
Custom Windows right-click command launching multiple instances[
^],
Enter multiple commands to only one process instance[
^].
Unfortunately, I have no idea what is your platform and language, so my information may be not 100% relevant, but you could use some ideas. Next time, please share such important detail.
(I mean, "PHP" and "Windows" is not enough. You need to provide information on "TestDlg.exe".)
—SA