VBA/Excel/Access/Word/Windows API/CPU Processor

Материал из VB Эксперт
Перейти к: навигация, поиск

Get CPU Processor Information

 
Type MEMORYSTATUS
   dwLength As Long
   dwMemoryLoad As Long
   dwTotalPhys As Long
   dwAvailPhys As Long
   dwTotalPageFile As Long
   dwAvailPageFile As Long
   dwTotalVirtual As Long
   dwAvailVirtual As Long
End Type
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
Declare Sub abGetSystemInfo Lib "kernel32" Alias "GetSystemInfo" (lpSystemInfo As SYSTEM_INFO)
Sub GetSysInfo()
    Dim intMousePresent As Integer
    Dim strBuffer As String
    Dim intLen As Integer
    Dim MS As MEMORYSTATUS
    Dim SI As SYSTEM_INFO
    abGetSystemInfo SI
    Debug.Print "ProcessorMask" & SI.dwActiveProcessorMask
    Debug.Print "NumberOfProcessors" & SI.dwNumberOrfProcessors
    Debug.Print "ProcessorType" & SI.dwProcessorType
End Sub



Get the Processor type and number of processors

 
Private Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As SYSTEM_INFO)
Type SYSTEM_INFO
   dwOemID As Long
   dwPageSize As Long
   lpMinimumApplicationAddress As Long
   lpMaximumApplicationAddress As Long
   dwActiveProcessorMask As Long
   dwNumberOfProcessors As Long
   dwProcessorType As Long
   dwAllocationGranularity As Long
   dwReserved As Long
End Type
Sub DisplaySystemInfo()
    Dim lpSysInfo As SYSTEM_INFO
    GetSystemInfo lpSysInfo
    Debug.Print "Number of processors: " & lpSysInfo.dwNumberOfProcessors
    Debug.Print "Processor type: " & lpSysInfo.dwProcessorType
End Sub