0
当处理器被认为是32位或64位时?我想检查一台PC是否有32位或64位处理器。那么如何在vb6代码中检查它? 虽然我正在研究它,但我得知我应该检查SYSTEM_INFO中的wProcessorArchitecture。当我按照它检查我的Windows 8 PC返回为32位。但是当我检查计算机属性时,它显示基于x64的处理器。 这里是代码检查处理器是32位还是64位
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
我不知道这是WOW仿真,使32个应用程序运行在64位Windows一无所知的一部分。 – tcarvin 2013-04-04 12:26:03
与确定处理器类型和少许黑客行为不太一样,我不知道这是否适用于Win8(通常适用于Win7),但是您可以检查安装的操作系统是否为64位版本(Check操作系统版本,或查看文件夹“C:\ Program Files(x86)”是否存在,或者搜索x86条目之一的环境变量等)。 – MarkL 2013-04-04 18:20:51
在过去的5年中,几乎所有的x86处理器都是64位的。看看OS是64位还是32位可能更有意义。 – Denis 2013-04-04 20:35:17