How to get PC hardware configuration details.

Posted on 2006-05-13
Last Modified: 2008-02-26
Some Microsoft apps determine the hardware configuration of the PC they are being installed on in order to prevent users from installing multiple copies. I would like to do the same for my Access apps.

How can you determine the hardware configuration details of a PC? The more info I can get about the configuration, the better.
Question by:Milewskp
    LVL 54

    Accepted Solution

    Check the sample database 11-13.mdb from the Access Cookbook: (select the Examples link and follow CDROM)
    The Chapter 11 zip holds it.

    LVL 1

    Author Comment

    Hi Nico,
    Thanks pretty good, but I'm was hoping to get more information on the hardware components; eg., the make and model of the:
    - CPU
    - Disk drives
    - hard drive
    - etc

    That is, the information that you see in the Device Manager panel (Control Panel/ Performance and Maintenance/ System/
    Hardware/ Device manager).  :-)
    LVL 54

    Expert Comment

    Diskdrives is in sample 11-12.mdb :-)

    CPU I haven't found yet, but I'll keep searching :-)

    The same booksamples holds however in chapter 4 (sample: 04-10.mdb) a way to secure your .mdb on userlevel....

    LVL 65

    Assisted Solution

    So whats left to get? just the CPU
    I can help u with that, anymore let me know, I (and Nico) will see what we can do

    paste this code in a module, then run the code  GetCPUDetails

    let me know what you think !!!

    Just one thing, I havent run this on a AMD machine yet, just Intel but it should work as it checks for different manufacturers

    Option Compare Database

    'Flags for GetSystemInfo
    Private Const PROCESSOR_INTEL_386 As Long = 386
    Private Const PROCESSOR_INTEL_486 As Long = 486
    Private Const PROCESSOR_INTEL_PENTIUM As Long = 586
    Private Const PROCESSOR_MIPS_R4000 As Long = 4000
    Private Const PROCESSOR_ALPHA_21064 As Long = 21064
    Private Const PROCESSOR_PPC_601 As Long = 601
    Private Const PROCESSOR_PPC_603 As Long = 603
    Private Const PROCESSOR_PPC_604 As Long = 604
    Private Const PROCESSOR_PPC_620 As Long = 620
    Private Const PROCESSOR_HITACHI_SH3 As Long = 10003    'Windows CE
    Private Const PROCESSOR_HITACHI_SH3E As Long = 10004   'Windows CE
    Private Const PROCESSOR_HITACHI_SH4 As Long = 10005    'Windows CE
    Private Const PROCESSOR_MOTOROLA_821 As Long = 821     'Windows CE
    Private Const PROCESSOR_SHx_SH3 As Long = 103          'Windows CE
    Private Const PROCESSOR_SHx_SH4 As Long = 104          'Windows CE
    Private Const PROCESSOR_STRONGARM As Long = 2577       'Windows CE - 0xA11
    Private Const PROCESSOR_ARM720 As Long = 1824          'Windows CE - 0x720
    Private Const PROCESSOR_ARM820 As Long = 2080          'Windows CE - 0x820
    Private Const PROCESSOR_ARM920 As Long = 2336          'Windows CE - 0x920
    Private Const PROCESSOR_ARM_7TDMI As Long = 70001      'Windows CE

    Private Const PROCESSOR_ARCHITECTURE_PPC As Long = 3
    Private Const PROCESSOR_ARCHITECTURE_SHX As Long = 4
    Private Const PROCESSOR_ARCHITECTURE_ARM As Long = 5
    Private Const PROCESSOR_ARCHITECTURE_IA64 As Long = 6
    Private Const PROCESSOR_ARCHITECTURE_ALPHA64 As Long = 7

    Private Const PROCESSOR_LEVEL_80386 As Long = 3
    Private Const PROCESSOR_LEVEL_80486 As Long = 4
    Private Const PROCESSOR_LEVEL_PENTIUM As Long = 5
    Private Const PROCESSOR_LEVEL_PENTIUMII As Long = 6

    Private Const sCPURegKey = "HARDWARE\DESCRIPTION\System\CentralProcessor\0"

    Private Const HKEY_LOCAL_MACHINE As Long = &H80000002

    Private Type SYSTEM_INFO
       dwOemID As Long
       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 GetSystemInfo Lib "kernel32" _
       (lpSystemInfo As SYSTEM_INFO)

    Private Declare Function RegCloseKey Lib "advapi32" _
       (ByVal hKey As Long) As Long

    Private Declare Function RegOpenKey Lib "advapi32" _
       Alias "RegOpenKeyA" _
      (ByVal hKey As Long, _
       ByVal lpSubKey As String, _
       phkResult As Long) As Long

    Private Declare Function RegQueryValueEx Lib "advapi32" _
       Alias "RegQueryValueExA" _
      (ByVal hKey As Long, _
       ByVal lpValueName As String, _
       ByVal lpReserved As Long, _
       lpType As Long, _
       lpData As Any, _
       lpcbData As Long) As Long

    Public Sub GetCPUDetails()

       Dim SI As SYSTEM_INFO
       Dim tmp As String
       Call GetSystemInfo(SI)
       MsgBox "Number Of Processors : " & SI.dwNumberOfProcessors
       Select Case SI.dwProcessorType
          Case PROCESSOR_INTEL_386: tmp = "386"
          Case PROCESSOR_INTEL_486: tmp = "486"
          Case PROCESSOR_INTEL_PENTIUM: tmp = "Pentium"
          Case PROCESSOR_MIPS_R4000: tmp = "MIPS 4000"
          Case PROCESSOR_ALPHA_21064: tmp = "Alpha"
       End Select

       MsgBox "Processor Type : " & SI.dwProcessorType & vbCrLf & tmp

       Select Case SI.wProcessorLevel
          Case PROCESSOR_LEVEL_80386: tmp = "Intel 80386"
          Case PROCESSOR_LEVEL_80486: tmp = "Intel 80486"
          Case PROCESSOR_LEVEL_PENTIUM: tmp = "Intel Pentium"
          Case PROCESSOR_LEVEL_PENTIUMII: tmp = "Intel Pentium Pro, II, III or 4"
       End Select
       MsgBox "Processor Level : " & SI.wProcessorLevel & vbCrLf & tmp
       MsgBox "Processor Revision : " & SI.wProcessorRevision & vbCrLf & _
              "Model : " & HiByte(SI.wProcessorRevision) & vbCrLf & _
              "Stepping : " & LoByte(SI.wProcessorRevision)

       MsgBox "CPU Speed : " & GetCPUSpeed() & " MHz"

    End Sub

    Private Function GetCPUSpeed() As Long
       Dim hKey As Long
       Dim cpuSpeed As Long
      'Open CPU key
       Call RegOpenKey(HKEY_LOCAL_MACHINE, sCPURegKey, hKey)
      'and retrieve the value
       Call RegQueryValueEx(hKey, "~MHz", 0, 0, cpuSpeed, 4)
       Call RegCloseKey(hKey)
       GetCPUSpeed = cpuSpeed

    End Function

    Public Function HiByte(ByVal wParam As Integer) As Byte
      'note: VB4-32 users should declare this function As Integer
       HiByte = (wParam And &HFF00&) \ (&H100)

    End Function

    Public Function LoByte(ByVal wParam As Integer) As Byte

      'note: VB4-32 users should declare this function As Integer
       LoByte = wParam And &HFF&

    End Function

    LVL 9

    Assisted Solution

    Would 'Environ("Processor_Identifier")' be sufficient?

    On my box this is the result: x86 Family 15 Model 3 Stepping 4, GenuineIntel
    LVL 1

    Author Comment

    I checked out sample 11-12.mdb. All I could see what the drive letters (eg C, D, etc? Is this what you meant by disk drive ID?
    I looked for 04-10.mdb, but it only goes up to 4-9.mdb.
    LVL 54

    Expert Comment

    11-12: Correct,it's in the text that you can use the GetVolumeInformation for more information.
    04-10: Is a text paragraph and I took the window from the Wrkgadm.exe as being part ofa sample :-(
    It's a feature for creating a unique identifier based on the Workgroup ID.

    LVL 1

    Author Comment

    I've found a few internet sites that show you how to get the manufacturer's serial number (not the serial number of the volume, which changes when you reformat) for the hard drives of a PC; eg    

    But these methods are coded in Does anyone know how to do it in vba?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
    Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now