How can I make sure that only a single instance of my program is running on a given machine?

John Mitchell

In terms of "economic" control, the only way is to have your applications only work in conjunction with a server which you control.

If you don't care so much about such a fascist level of control, the basic solution is the same as How can I determine when multiple instances of my program are running on the same machine?.