I had ran into the same problem before.
I was using atoms and mutexes to identify unique instances of the main window.
(I only wanted only one instance of my app to be alive at any one given time)
Funny that i had crashed my program purposly just to see what happens.
In the end i had just used FindWindow() with the main window classname.
There may be other ways to do it, but this way is the easiest i found.