Getting Computer Information

J

JohnV

I have some applications that can run from 30 minutes to 1 1/2 hours
depending upon which computer and where the database is located. To benchmark
my applications, I store the times it takes to run different parts of the
application.

What I would like to do is get the Computer Information for the following:
CPU Intel Pentium 4 CPU 2.80GHz
1.00 GB of RAM
Network Adapter 100Mbps

Is there any way to get that level of information?

Thanks,
JohnV
 
D

Douglas J. Steele

You should be able to get that information using WMI (Windows Management
Instrumentation)

Afraid I don't have specific code I can show you, though. Randy Birch has
some stuff at http://vbnet.mvps.org/code/wmi/index.html, but be aware that
his site is aimed at VB programmers: because there are significant
differences between forms in VB and Access, some of his examples don't port
directly to Access.

There's also lots at
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/wmi_reference.asp and
http://msdn.microsoft.com/downloads/list/wmi.asp and
http://www.microsoft.com/technet/scriptcenter/default.mspx
 
D

Douglas J Steele

Found an example for you:

'----- Start of Example -----
Option Compare Database
Option Explicit

Private Declare Function GetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Sub MachineInformation()
Const wbemFlagReturnImmediately = &H10
Const wbemFlagForwardOnly = &H20

Dim strComputer As String
Dim strPowerManagementCapabilities As String
Dim objWMIService As Object
Dim colItems As Object
Dim objItem As Object
Dim lngLen As Long, lngX As Long

lngLen = 16
strComputer = String$(lngLen, 0)
lngX = GetComputerName(strComputer, lngLen)
If lngX <> 0 Then
strComputer = Left$(strComputer, lngLen)
Else
strComputer = ""
End If

Debug.Print
Debug.Print "=========================================="
Debug.Print "Computer: " & strComputer
Debug.Print "=========================================="

Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor",
"WQL", _
wbemFlagReturnImmediately +
wbemFlagForwardOnly)

For Each objItem In colItems
Debug.Print "AddressWidth: " & objItem.AddressWidth
Debug.Print "Architecture: " & objItem.Architecture
Debug.Print "Availability: " & objItem.Availability
Debug.Print "Caption: " & objItem.Caption
Debug.Print "ConfigManagerErrorCode: " &
objItem.ConfigManagerErrorCode
Debug.Print "ConfigManagerUserConfig: " &
objItem.ConfigManagerUserConfig
Debug.Print "CpuStatus: " & objItem.CpuStatus
Debug.Print "CreationClassName: " & objItem.CreationClassName
Debug.Print "CurrentClockSpeed: " & objItem.CurrentClockSpeed
Debug.Print "CurrentVoltage: " & objItem.CurrentVoltage
Debug.Print "DataWidth: " & objItem.DataWidth
Debug.Print "Description: " & objItem.Description
Debug.Print "DeviceID: " & objItem.DeviceID
Debug.Print "ErrorCleared: " & objItem.ErrorCleared
Debug.Print "ErrorDescription: " & objItem.ErrorDescription
Debug.Print "ExtClock: " & objItem.ExtClock
Debug.Print "Family: " & objItem.Family
Debug.Print "L2CacheSize: " & objItem.L2CacheSize
Debug.Print "L2CacheSpeed: " & objItem.L2CacheSpeed
Debug.Print "LastErrorCode: " & objItem.LastErrorCode
Debug.Print "Level: " & objItem.Level
Debug.Print "LoadPercentage: " & objItem.LoadPercentage
Debug.Print "Manufacturer: " & objItem.Manufacturer
Debug.Print "MaxClockSpeed: " & objItem.MaxClockSpeed
Debug.Print "Name: " & objItem.Name
Debug.Print "OtherFamilyDescription: " &
objItem.OtherFamilyDescription
Debug.Print "PNPDeviceID: " & objItem.PNPDeviceID
Debug.Print "PowerManagementSupported: " &
objItem.PowerManagementSupported
Debug.Print "ProcessorId: " & objItem.ProcessorId
Debug.Print "ProcessorType: " & objItem.ProcessorType
Debug.Print "Revision: " & objItem.Revision
Debug.Print "Role: " & objItem.Role
Debug.Print "SocketDesignation: " & objItem.SocketDesignation
Debug.Print "Status: " & objItem.Status
Debug.Print "StatusInfo: " & objItem.StatusInfo
Debug.Print "Stepping: " & objItem.Stepping
Debug.Print "SystemCreationClassName: " &
objItem.SystemCreationClassName
Debug.Print "SystemName: " & objItem.SystemName
Debug.Print "UniqueId: " & objItem.UniqueId
Debug.Print "UpgradeMethod: " & objItem.UpgradeMethod
Debug.Print "Version: " & objItem.Version
Debug.Print "VoltageCaps: " & objItem.VoltageCaps
Debug.Print
Next

End Sub
'----- End of Example -----

Just don't expect me to explain what the values mean! <g>
 
Top