Private Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As SYSTEM_INFO)
 
Private Type SYSTEM_INFO
    dwOemID As Long
    dwPageSize As Long
    lpMinimumApplicationAddress As Long
    lpMaximumApplicationAddress As Long
    dwActiveProcessorMask As Long
    dwNumberOrfProcessors As Long
    dwProcessorType As Long
    dwAllocationGranularity As Long
    dwReserved As Long
End Type

调用:

    Dim stSysInfo As SYSTEM_INFO
    GetSystemInfo stSysInfo
    MsgBox "当前机器的CPU是 " & CStr(stSysInfo.dwNumberOrfProcessors) & " 核", vbInformation, "提示"

 非常简单。