Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

How to obtain the description of the System's Processor
[ All Languages » VB »  Api]

Total Hit ( 3404)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


API Declarations

Click here to copy the following block
'API Structures
Public 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

Public Type OSVERSIONINFO
  dwOSVersionInfoSize As Long
  dwMajorVersion As Long
  dwMinorVersion As Long
  dwBuildNumber As Long
  dwPlatformId As Long
  szCSDVersion As String * 128
End Type

'API Calls
Public Declare Sub GetSystemInfo Lib "kernel32.dll" (lpSystemInfo As SYSTEM_INFO)
Public Declare Function GetVersionEx Lib "kernel32.dll" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long

'API Constants
Public Const PROCESSOR_ARCHITECTURE_ALPHA = 2
Public Const PROCESSOR_ARCHITECTURE_INTEL = 0
Public Const PROCESSOR_ARCHITECTURE_MIPS = 1
Public Const PROCESSOR_ARCHITECTURE_PPC = 3
Public Const PROCESSOR_ARCHITECTURE_UNKNOWN = &HFFFF
Public Const PROCESSOR_INTEL_386 = 386
Public Const PROCESSOR_INTEL_486 = 486
Public Const PROCESSOR_INTEL_PENTIUM = 586
Public Const PROCESSOR_INTEL_PENTIUM2 = 686
Public Const PROCESSOR_INTEL_PENTIUM3 = 786
Public Const PROCESSOR_MIPS_R4000 = 4000
Public Const VER_PLATFORM_WIN32_NT = 2
Public Const VER_PLATFORM_WIN32_WINDOWS = 1

Module

Click here to copy the following block
'get a string with the description of the system's processor
Public Function GetProcessorType() As String
  Dim si As SYSTEM_INFO
  Dim os As OSVERSIONINFO

  'retrive the Windows Platform
  os.dwOSVersionInfoSize = Len(os)
  GetVersionEx os
  'retrive the SYSTEM_INFO Structure
  GetSystemInfo si
  Select Case si.wProcessorArchitecture
  'Intel Architecture
  Case PROCESSOR_ARCHITECTURE_INTEL
    Select Case os.dwPlatformId
    Case VER_PLATFORM_WIN32_NT
      Select Case si.wProcessorLevel
      Case 3
        GetProcessorType = "Intel 80386"
        If (si.wProcessorRevision And &HFF00) = &HFF00 Then
          GetProcessorType = GetProcessorType And " Model " & ((si.wProcessorRevision And &HF0) / &HF) - 10 & " Stepping " & (si.wProcessorRevision And &HF)
        Else
          GetProcessorType = GetProcessorType And " Stepping " & Chr(Asc("A") + (si.wProcessorRevision And &HFF) / &HFF) & " Stepping " & (si.wProcessorRevision And &HFF)
        End If
      Case 4
        GetProcessorType = "Intel 80486"
        If (si.wProcessorRevision And &HFF00) = &HFF00 Then
          GetProcessorType = GetProcessorType And " Model " & ((si.wProcessorRevision And &HF0) / &HF) - 10 & " Stepping " & (si.wProcessorRevision And &HF)
        Else
          GetProcessorType = GetProcessorType And " Stepping " & Chr(Asc("A") + (si.wProcessorRevision And &HFF) / &HFF) & " Stepping " & (si.wProcessorRevision And &HFF)
        End If
      Case 5
        GetProcessorType = "Pentium Model " & (si.wProcessorRevision And &HFF00) \ &HFF & " Stepping " & (si.wProcessorRevision And &HFF)
      Case 6
        GetProcessorType = "Pentium II Model " & (si.wProcessorRevision And &HFF00) \ &HFF & " Stepping " & (si.wProcessorRevision And &HFF)
      Case 7
        GetProcessorType = "Pentium III Model " & (si.wProcessorRevision And &HFF00) \ &HFF & " Stepping " & (si.wProcessorRevision And &HFF)
      End Select
    Case VER_PLATFORM_WIN32_WINDOWS
      Select Case si.dwProcessorType
      Case PROCESSOR_INTEL_386
        GetProcessorType = "Intel 80386"
      Case PROCESSOR_INTEL_486
        GetProcessorType = "Intel 80486"
      Case PROCESSOR_INTEL_PENTIUM
        GetProcessorType = "Pentium"
      Case PROCESSOR_INTEL_PENTIUM2
        GetProcessorType = "Pentium II"
      Case PROCESSOR_INTEL_PENTIUM3
        GetProcessorType = "Pentium III"
      End Select
    End Select
  'MIPS Architecture (only for WinNT)
  Case PROCESSOR_ARCHITECTURE_MIPS
    GetProcessorType = "MIPS R" & si.wProcessorLevel & "000"
  'ALPHA Architecture (only for WinNT)
  Case PROCESSOR_ARCHITECTURE_ALPHA
    GetProcessorType = "Alpha " & si.wProcessorLevel & " Model A" & (si.wProcessorRevision And &HFF00) \ &HFF & " Pass " & (si.wProcessorRevision And &HFF)
  'PPC Architecture (only for WinNT)
  Case PROCESSOR_ARCHITECTURE_PPC
    Select Case si.wProcessorLevel
    Case 1, 3, 4, 20
      GetProcessorType = "PPC 6" & Format(si.wProcessorLevel, "00")
    Case 6
      GetProcessorType = "PPC 603+"
    Case 9
      GetProcessorType = "PPC 604+"
    End Select
    GetProcessorType = GetProcessorType & " Processor Version " & (si.wProcessorRevision And &HFF00) \ &HFF & "." & (si.wProcessorRevision And &HFF)
  End Select
End Function

Usage

Click here to copy the following block
Private Sub Command1_Click()
  MsgBox GetProcessorType
End Sub


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.