Suppose we have a text editor application that runs with one separate process per form. The application is single document (i.e. no tabs or MDI).
We have three forms open with three documents, A.txt, B.txt and C.txt. Now the user double clicks the B.txt file on his desktop. This starts a new instance of the application in question. This launched instance of the editor should now exit and focus/bring to front the already running process that has this file loaded, so that the user does not end up withe same document loaded in two separate forms.
How can I achieve this most easily? In other words, how can I find which process is already showing a document?
The files are not held open by the application once opened, so I can't rely on enumerating the file handles of processes to find the process. I presume this requires some form of communication between the processes. Ideally I'm looking for a .NET solution, but the question is really windows related/language-agnostic.
EDIT: I should mention that for various reasons I'm trying to use separate processes instead of running all forms in a single process.