[DllImport("kernel32.dll")]
public static extern void GetSystemInfo()
out SystemInfo input
);
public static SystemInfo GetSystemInfo()
{
var stub = new SystemInfo();
GetSystemInfo(out stub);
return stub;
}
public enum ProcessorArchitecture
{
X86 = 0,
X64 = 9,
@Arm = -1,
Itanium = 6,
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
}
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