当处理器被认为是32位还是64位?我想检查一台PC是否有32位或64位处理器。那么如何在vb6代码中检查呢? 当我正在研究它时,我得到了我应该检查SYSTEM_INFO中的wProcessorArchitecture。当我根据它检查我的Windows 8 PC返回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
答案 0 :(得分:0)
GetNativeSystemInfo
不返回处理器的体系结构。相反,它返回操作系统的体系结构。即在32位版本的Windows中调用它时,总是得到“32位”。
您在问题中引用的MSDN文章:
<强> wProcessorArchitecture 强>
已安装操作系统的处理器架构 。该成员可以是以下值之一。
有关如何确定CPU架构的信息,请参阅此问题:check OS and processor is 32 bit or 64 bit?