getsysteminfo (kernel32)
Last changed: Milkenm-65.49.2.17

.
Summary
Retrieves information about the current system

C# Signature:

[DllImport("kernel32.dll", SetLastError=false)]

public static extern void GetSystemInfo(out SYSTEM_INFO Info);

User-Defined Types:

    public enum ProcessorArchitecture
    {
        X86 = 0,
        Arm = 5,
        Itanium = 6,
        X64 = 9,
        ARM64 = 12,
        Unknown = 0xFFFF,
    }

    [StructLayout(LayoutKind.Sequential)]
    public struct SystemInfo
    {
        public ProcessorArchitecture ProcessorArchitecture; // WORD
        public uint PageSize; // DWORD
        public IntPtr MinimumApplicationAddress; // (long)void*
        public IntPtr MaximumApplicationAddress; // (long)void*
        public IntPtr ActiveProcessorMask; // DWORD*
        public uint NumberOfProcessors; // DWORD (WTF)
        public uint ProcessorType; // DWORD
        public uint AllocationGranularity; // DWORD
        public ushort ProcessorLevel; // WORD
        public ushort ProcessorRevision; // WORD
    }

Alternative C# structure[s]: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724958%28v=vs.85%29.aspx

    [StructLayout( LayoutKind.Explicit )]
    public struct SYSTEM_INFO_UNION
    {
        [FieldOffset( 0 )]
        public UInt32 OemId;
        [FieldOffset( 0 )]
        public UInt16 ProcessorArchitecture;
        [FieldOffset( 2 )]
        public UInt16 Reserved;
    }

    [StructLayout( LayoutKind.Sequential, Pack = 1 )]
    public struct SYSTEM_INFO
    {
        public SYSTEM_INFO_UNION CpuInfo;
        public UInt32 PageSize;
        public UInt32 MinimumApplicationAddress;
        public UInt32 MaximumApplicationAddress;
        public UInt32 ActiveProcessorMask;
        public UInt32 NumberOfProcessors;
        public UInt32 ProcessorType;
        public UInt32 AllocationGranularity;
        public UInt16 ProcessorLevel;
        public UInt16 ProcessorRevision;
    }

Alternative Managed API:

To determine whether the OS or Process is x64, using .NET 4, see System.Environment (Is64BitProcess, Is64BitOperatingSystem); http://msdn.microsoft.com/en-us/library/z8te35sa.aspx

Sample Code:

    void Test()
    {
        NativeMethods.SYSTEM_INFO
         info;
        NativeMethods.GetSystemInfo(out info);
    }

Documentation