For a variety of reasons it is often desirable to limit the number of running instances of a program to exactly one on a particular computer. There is a lot of folklore around about how to do this, and much of it is wrong. There are a few good methods, and a lot of flawed ones.
I know. I used a flawed one for years. I even put the technique in our book, "Win32 Programming". I feel suitably embarrassed.
This essay examines some of the many solutions, and points out the problems in those that will fail, and the conditions under which they fail.
What is really dangerous is that Microsoft not only does not document the correct method, but offers two code examples of a fatally-flawed solution, which I discuss in detail.
Comments