-
help....
Is there a code that will only allow one instance of your app to be opened....
Then when the code detects that another instance is running is there a way to pass the command line on to the already running instance.....
What i have is my program opens a mp3 file when you double click on them....but when i click on a mp3 it opens my app and then i click on another mp3 it opens another one of my apps. So each time i click a mp3 i get a new app.
Hope this makes sense.
any help would bee great...
Thanks
-
Read up on singleton design patterns.
-
any link that you know....or any direction to go?
-
Still wondering....
I have looked but still can not find any direction to go...
-
This idea has been discussed many times. I think there is no flawless way of not letting another instance of application being run. What I used in my programs was creating a very strong named Mutex based on assembly GUID. Then trying to take the ownership of the mutex. If it failed it means that another instance has taken the ownership so this instance stopped running. But till now I haven't found a way to find the process that is taking the ownership of mutex, so that I can send parameters to that.
Another way is to checking the pool of processes and see if a process with the same name as yours is running, if so you send the parameters to that process and quit this one. However it is not a guaranteed way.
There is good thread about it in VBCity.
http://www.vbcity.com/forums/topic.asp?tid=25500