I need to be able to lookup the type of CPU that my application is running from a .NET Compact Framework application. Basically, I need to know if I'm on an ARM, SH4, x86, etc processor.
+2
A:
You can get this information from the GetSystemInfo API call:
[DllImport("coredll")]
static extern void GetSystemInfo(ref SYSTEM_INFO pSI);
public struct SYSTEM_INFO
{
public uint dwOemId;
public uint dwPageSize;
public uint lpMinimumApplicationAddress;
public uint lpMaximumApplicationAddress;
public uint dwActiveProcessorMask;
public uint dwNumberOfProcessors;
public uint dwProcessorType;
public uint dwAllocationGranularity;
public uint dwProcessorLevel;
public uint dwProcessorRevision;
}
Running on the emulator, dwProcessorType returns 2577, which as I recall is the ID of the ARM processor, so this will work (although you'll need to dig up which values refer to which processors).
You'll need this using directive for the above code to work, of course:
using System.Runtime.InteropServices;
MusiGenesis
2009-09-24 15:46:50