This is not a C++ solution, but it seems to work in C#.
However should be easily converted to C++ because the key point is in the API structure SYSTEM_INFO and the API GetNativeSystemInfo()
First a reference to the API that gets infos
[DllImport("kernel32.dll")] public static extern void GetNativeSystemInfo ([MarshalAs(UnmanagedType.Struct)] ref SYSTEM_INFO lpSystemInfo);
then the structure SYSTEM_INFO and the _PROCESSOR_INFO_UNION
[StructLayout(LayoutKind.Sequential)] public struct SYSTEM_INFO { internal _PROCESSOR_INFO_UNION uProcessorInfo; public uint dwPageSize; public IntPtr lpMinimumApplicationAddress; public IntPtr lpMaximumApplicationAddress; public IntPtr dwActiveProcessorMask; public uint dwNumberOfProcessors; public uint dwProcessorType; public uint dwAllocationGranularity; public ushort dwProcessorLevel; public ushort dwProcessorRevision; } [StructLayout(LayoutKind.Explicit)] public struct _PROCESSOR_INFO_UNION { [FieldOffset(0)] internal uint dwOemId; [FieldOffset(0)] internal ushort wProcessorArchitecture; [FieldOffset(2)] internal ushort wReserved; }
Now an enum to simplify the code and the method that calls the native API
public enum ProcessorArchitecture { Unknown = 0, Bit32 = 1, Bit64 = 2, Itanium64 = 3 } static public ProcessorArchitecture ProcessorBits { get { ProcessorArchitecture pbits = ProcessorArchitecture.Unknown; SYSTEM_INFO l_System_Info = new SYSTEM_INFO(); GetNativeSystemInfo(ref l_System_Info); switch (l_System_Info.uProcessorInfo.wProcessorArchitecture) { case 9: // PROCESSOR_ARCHITECTURE_AMD64 pbits = ProcessorArchitecture.Bit64; break; case 6: // PROCESSOR_ARCHITECTURE_IA64 pbits = ProcessorArchitecture.Itanium64; break; case 0: // PROCESSOR_ARCHITECTURE_INTEL pbits = ProcessorArchitecture.Bit32; break; default: // PROCESSOR_ARCHITECTURE_UNKNOWN pbits = ProcessorArchitecture.Unknown; break; } return pbits; } }