How to make a single instance program in C++

I just discovered a neat trick for enforcing a single instance of a C++ program.