-2

I've been struggling with this for more than several hours and cannot think of a solution.

I have an application that can be started in this way:

TestApplication.exe ID={GUID} filename={filename}

If there is not an instance of the application with the same GUID, a new instance should be started with ID={GUID} and the specified file should be loaded in it.

If there is an instance of the application with the same GUID, the user should be asked if he wants to close the file he is working on and if he confirms it - then the new file specified should be opened in the running instance.

Any ideas how to implement this?

dobri
  • 57
  • 1
  • 4

2 Answers2

0

Use a Mutex. See the first answer of this question: What is the correct way to create a single-instance application?

Community
  • 1
  • 1
hillin
  • 1,603
  • 15
  • 21
  • This does not address how to communicate between the processes, if a process with a given GUID already exists. – IInspectable Apr 27 '16 at 06:20
  • 1
    @IInspectable Then try the second answer in the post I mentioned, teaches you how to pass args. Try search before ask. – hillin Apr 27 '16 at 06:24
  • If you think this question has been asked before, and already has an answer, you should vote to close as duplicate instead of posting a link the the duplicate in an answer. – IInspectable May 01 '16 at 12:45
0

Any ideas how to implement this?

Yes. Question answered. You never ask us to show us our ideas.

Let's get real.

  • One way is by window title, but having the GUID there is seriously not optimal.

  • As such, read up on NAMED MUTEXES. You can use that one to identify a program already running.

  • Alternatively - and better given you must actually send a signal - named pipes. You can register a named pipe with the GUID. Fails: Already exists. THAT allows the new application to actually signal the old one and or send a shutdown command.

TomTom
  • 61,059
  • 10
  • 88
  • 148