I’ve made MP3 Files on my computer to associate with my media player.
So when i double click a MP3 file in the explorer, obviously the media player fires up and plays it.
My problem
I can prevent multiple instances popping up, but how can i transfer the file path of the new instance to the instance i am using already
What i want to happen:
I double click a song,… and im listening to it
I double click another song
and the current song should stop and new song should start playback, without popping up a new instance of the application.
I use Mutex to check whether there is already a running instance.
To get file path i use Environment.GetCommandLineArgs()
All I need is to pass the file’s path to the current instance. How can I do this??
Essentially you will have to build this into your application.
When a user clicks a second song, you would have to have some way for the current instance to kill the previous instance of your application or send it a message.
These seems a little dirty to me.
I think a clean approach would be to write a small
app_booter.exethat is associated with your media files. When a media file is clicked, it starts this _app_booter_ which :To send your application data from this other exe you could take a look at IPC:
Interprocess communication for Windows in C# (.NET 2.0)
I think the
WM_COPYDATAapproach mentioned in the above post, or a tcp socket would suffice since your data is pretty simple, just a file path and maybe a command.I think keeping two separate exes will be easier and cleaner than building your app to talk to its previous instance.