Je dois pouvoir rechercher le type de CPU que mon application exécute à partir d'une application .NET Compact Framework. Fondamentalement, j'ai besoin de savoir si je suis sur un processeur ARM, SH4, x86, etc.Rechercher Type de CPU dans .NET Compact Framework
1
A
Répondre
2
Vous pouvez obtenir ces informations de l'appel API GetSystemInfo:
[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;
}
Fonctionnant sur l'émulateur, dwProcessorType retourne 2577, qui, comme je me souviens est l'ID du processeur ARM, donc ça marchera (bien que vous Il va falloir déterrer quelles valeurs se réfèrent à quels processeurs).
Vous aurez besoin de cette directive à l'aide du code ci-dessus fonctionne, bien sûr:
using System.Runtime.InteropServices;