I once had a requirement for the same problem. I figured out the solution but never made a point to blog it. But recently few others had the same issue and I had to think again how I did it. Anyway here is the simple method which tells you if you are running a 64-bit OS.
public bool Is64BitMachine()
return IntPtr.Size == 8;
The idea is to use size of the IntPtr to determine if it is 64-bit or 32-bit. In case of 32-bit machines, IntPtr size is 4 bytes.