C# 怎样得到本机CPU的核心数?

如题?在C#程序员,怎样得到CPU的核心数?
2024-11-30 05:03:40
推荐回答(1个)
回答1:

void WINAPI GetSystemInfo(
__out LPSYSTEM_INFO lpSystemInfo
);
LPSYSTEM_INFO 这个结构里有dwNumberOfProcessors,

typedef struct _SYSTEM_INFO {
union {
DWORD dwOemId;
struct {
WORD wProcessorArchitecture;
WORD wReserved;
} ;
} ;
DWORD dwPageSize;
LPVOID lpMinimumApplicationAddress;
LPVOID lpMaximumApplicationAddress;
DWORD_PTR dwActiveProcessorMask;
DWORD dwNumberOfProcessors;
DWORD dwProcessorType;
DWORD dwAllocationGranularity;
WORD wProcessorLevel;
WORD wProcessorRevision;
} SYSTEM_INFO;