Windows 检查处理器是否为32位或64位
处理器是32位还是64位?我想检查电脑是否有32位或64位处理器。那么如何在vb6代码中检查它呢? 当我研究它的时候,我发现我应该检查一下wProcessorArchitecture。当我根据它检查时,我的windows 8 pc返回为32位。但当我检查计算机属性时,它显示基于x64的处理器。 下面是代码的一部分Windows 检查处理器是否为32位或64位,windows,windows-8,vb6,Windows,Windows 8,Vb6,处理器是32位还是64位?我想检查电脑是否有32位或64位处理器。那么如何在vb6代码中检查它呢? 当我研究它的时候,我发现我应该检查一下wProcessorArchitecture。当我根据它检查时,我的windows 8 pc返回为32位。但当我检查计算机属性时,它显示基于x64的处理器。 下面是代码的一部分 Option Explicit Private Type SYSTEM_INFO wProcessorArchitecture As Integer wReserv
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
选项显式
私有类型系统信息
wProcessorArchitecture作为整数
被用作整数
dwPageSize尽可能长
lpMinimumApplicationAddress尽可能长
lpMaximumApplicationAddress尽可能长
dwActiveProcessorMask尽可能长
dwNumberOfProcessors尽可能长
dwProcessorType尽可能长
dwAllocationGranularity尽可能长
wProcessorLevel为整数
wProcessorRevision为整数
端型
私有声明子GetNativeSystemInfo库“kernel32”(lpSystemInfo作为系统信息)
'GetSystemInfo和GetNativeSystemInfo API函数的常量(系统信息结构)
专用常量处理器\u体系结构\u AMD64,长度为9'x64(AMD或Intel)
专用常量处理器\u体系结构\u IA64,长度=6'英特尔安腾处理器系列(IPF)
专用常量处理器\u体系结构\u英特尔长度=0'x86
私有常量处理器\u体系结构\u未知长度=&HFFFF&“未知体系结构”
公共函数ISOS64位()为布尔值
关于错误转到ProcError
作为系统信息的尺寸类型
调用GetNativeSystemInfo(典型)
如果(typ_si.wProcessorArchitecture=处理器体系结构\u AMD64)或(typ_si.wProcessorArchitecture=处理器体系结构\u IA64),则
ISOS64位=真
MsgBox“64位”
其他的
ISOS64位=假
MsgBox“32位”
MsgBox典型si.W处理器体系结构
如果结束
ProcClean:
Debug.Print“退出函数m_OS64.IsOS64Bit()”
退出功能
程序错误:
如果错误号为0,则
Debug.Print“m_OS64.IsOS64Bit()中发生错误”
调试.打印错误号&“:”&错误说明
恢复清洁
如果结束
端函数
专用子命令1_Click()
调用ISOS64位
端接头
GetNativeSystemInfo
不返回处理器的体系结构。相反,它返回操作系统的体系结构。也就是说,在32位版本的Windows中调用它时,总是会得到“32位”
根据您在问题中引用的MSDN文章:
wProcessorArchitecture
已安装操作系统的处理器体系结构。此成员可以是以下值之一
有关如何确定CPU体系结构的信息,请参见此问题:我想知道这是否是WOW仿真的一部分,它允许32位应用程序在64位Windows上不自觉地运行。这与确定处理器类型不太一样,有点麻烦,我不知道这是否适用于Win8(通常适用于Win7),但您可以检查安装的操作系统是否为64位版本(检查操作系统版本,或查看文件夹“C:\Program Files(x86)”是否存在,或搜索环境变量中的某个x86条目,等等)。过去5年制造的几乎所有x86处理器都是64位的。看看操作系统是64位还是32位可能更有意义。@winman这个问题你已经有了答案