There are several applications, more than one process of which cannot run at a time. For example, we cannot run two instances of Window Media Player. Even if we click on the exe multiple times, another process will not start!
I was wondering how to do that in the following situations :
- if the application is developed in C++. The application needn’t to be a GUI based application.
- if the application is developed using .NET technologies. Again, the application needn’t to be a GUI based application.
I’ve absolutely no idea about this, so don’t even know how to pose the question appropriately. If I’m missing anything (any sort of detail), please feel free to ask for clarification, or assume (if thats possible) in your answer.
Typically the application needs to try to acquire some unique resource on startup; if it fails, it should exit. The nature of the unique resource varies by environment — for example, it could be listening on a particular TCP port, or locking a file or shared memory segment. The program then needs to be careful to free the resource when it exits, of course.