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