CPU Test - 32 bit or 64 bit

When is a processor considered 32-bit or 64-bit? I want to check if the PC has a 32-bit or 64-bit processor. So how can I check this in vb6 code? While I was doing research, I realized that I had to check wProcessorArchitecture in SYSTEM_INFO . When I check according to this, my Windows 8 pc returns as 32 bits. But when I check the properties of the computer, it shows an x64-based processor. here is the piece of code

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
source share
1 answer

GetNativeSystemInfo does NOT return processor architecture. Instead, it returns the operating system architecture. That is, you always get "32 bits" when called on a 32-bit version of Windows.

From the MSDN article that you are referring to in the question:

wProcessorArchitecture

The processor architecture of the installed operating system . This member can be one of the following values.

See this question for information on how to determine the architecture of the CPU: check the operating system and processor for 32-bit or 64-bit?

0
source

All Articles