何时将处理器视为 32 位或 64 位?我想检查 PC 是 32 位还是 64 位处理器。那么如何在 vb6 代码中检查它呢?当我研究它时,我知道我应该检查SYSTEM_INFO中的 wProcessorArchitecture 。当我根据它检查时,我的 Windows 8 电脑返回为 32 位。但是当我检查计算机属性时,它显示基于 x64 的处理器。这是代码的一部分
Option Explicit
Private Type SYSTEM_INFO
wProcessorArchitecture As Integer
wReserved As Integer
dwPageSize As Long
lpMinimumApplicationAddress As Long
lpMaximumApplicationAddress As Long
dwActiveProcessorMask As Long
dwNumberOfProcessors As Long
dwProcessorType As Long
dwAllocationGranularity As Long
wProcessorLevel As Integer
wProcessorRevision As Integer
End Type
Private Declare Sub GetNativeSystemInfo Lib "kernel32" (lpSystemInfo As SYSTEM_INFO)
'Constants for GetSystemInfo and GetNativeSystemInfo API functions (SYSTEM_INFO structure)
Private Const PROCESSOR_ARCHITECTURE_AMD64 As Long = 9 'x64 (AMD or Intel)
Private Const PROCESSOR_ARCHITECTURE_IA64 As Long = 6 'Intel Itanium Processor Family (IPF)
Private Const PROCESSOR_ARCHITECTURE_INTEL As Long = 0 'x86
Private Const PROCESSOR_ARCHITECTURE_UNKNOWN As Long = &HFFFF& 'Unknown architecture
Public Function IsOS64Bit() As Boolean
On Error GoTo ProcError
Dim typ_si As SYSTEM_INFO
Call GetNativeSystemInfo(typ_si)
If (typ_si.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64) Or (typ_si.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64) Then
IsOS64Bit = True
MsgBox "64 bit"
Else
IsOS64Bit = False
MsgBox "32 bit"
MsgBox typ_si.wProcessorArchitecture
End If
ProcClean:
Debug.Print "Exiting Function m_OS64.IsOS64Bit()"
Exit Function
ProcError:
If Err.Number <> 0 Then
Debug.Print "An error occured in m_OS64.IsOS64Bit()"
Debug.Print Err.Number & ": " & Err.Description
Resume ProcClean
End If
End Function
Private Sub Command1_Click()
Call IsOS64Bit
End Sub