DotNetLogo
We have a lot of ways to check the Operating System architecture in .NET, the .NET Framework v4.0 already has this method on their libraries, but many people still are using previous versions (as v3.5 or v2.0).

For the people that use the .NET v4.0 or higher, it is really simple, just call the ‘Environment.Is64BitOperatingSystem’ property and check if is true or false.:

        if (Environment.Is64BitOperatingSystem)
            Console.WriteLine("Your OS is 64 bits.");
        else Console.WriteLine("Your OS is 32 bits.");

But for the people using v3.5 or previous, I have this simple way compatible with ‘x86′, ‘x64′ and ‘AnyCPU’ architectures:

        /*

         * Is64BitOperatingSystem C# method by Michel Oliveira.
         * 2013/05/14
         * www.joshcellsoftwares.com

         GPL License.

         */

    public static bool Is64BitOperatingSystem()
    {
        if (!Environment.GetFolderPath(Environment.SpecialFolder.SystemX86).ToUpper().Contains("SYSTEM32"))
            return true; //Check for the SystemX86 variable. If is not 'SYSTEM32' then the Operating System is x64 (SystemX86 = SYSWOW64).
        return false; //Return false when the method was not blocked by the if statement.
    }
'
'
'         * Is64BitOperatingSystem VB.NET method by Michel Oliveira.
'         * 2013/05/14
'         * www.joshcellsoftwares.com
'
'         GPL License.
'
'
Public Shared Function Is64BitOperatingSystem() As Boolean
	If Not Environment.GetFolderPath(Environment.SpecialFolder.SystemX86).ToUpper().Contains("SYSTEM32") Then
		Return True
	End If
	'Check for the SystemX86 variable. If is not 'SYSTEM32' then the Operating System is x64 (SystemX86 = SYSWOW64).
	Return False
	'Return false when the method was not blocked by the if statement.
End Function

This way is really fast and accurate, one time that you will not need of external calls and are doing the process natively. The usage is very simple:

        if (Is64BitOperatingSystem())
            Console.WriteLine("Your OS is 64 bits.");
        else Console.WriteLine("Your OS is 32 bits.");

We also have a way to do it by checking the IntPtr Size:

        if (IntPtr.Size == 8)
            Console.WriteLine("Your OS is 64 bits.");
        else Console.WriteLine("Your OS is 32 bits.");

‘IntPtr.Size’ always will be eight when the process is running in memory as x64, but only will work if your project was made using the ‘AnyCPU’ platform.

Good Luck,

Michel Oliveira – Software Engineer and Startup founder at joshcellsoftwares.com.