Next code will definetely will work on WinNT, but may not work on Win95/98 (can't test it right now, don't have it here at work). Add a Listbox (List1) and a CommandButton (Command1) to the form.
Module Code
Form CodeCode: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.dll" (ByVal hKey As Long) As Long Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long Private Declare Function RegQueryValueEx Lib "advapi32.dll" 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 Private Const HKEY_LOCAL_MACHINE As Long = &H80000002 Private Const PROCESSOR_INTEL_386 = 386 Private Const PROCESSOR_INTEL_486 = 486 Private Const PROCESSOR_INTEL_PENTIUM = 586 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 Public Type udtCPU lClockSpeed As Long lProcType As Integer strProcLevel As String strProcRevision As String lNumberOfProcessors As Long End Type Public Function GetCPUInfo(ptCPUInfo As udtCPU) Dim tSYS As SYSTEM_INFO Dim intProcType As Integer Dim strProcLevel As String Dim strProcRevision As String Call GetSystemInfo(tSYS) Select Case tSYS.dwProcessorType Case PROCESSOR_INTEL_386: intProcType = 386 Case PROCESSOR_INTEL_486: intProcType = 486 Case PROCESSOR_INTEL_PENTIUM: intProcType = 586 End Select Select Case tSYS.wProcessorLevel Case PROCESSOR_LEVEL_80386: strProcLevel = "Intel 80386" Case PROCESSOR_LEVEL_80486: strProcLevel = "Intel 80486" Case PROCESSOR_LEVEL_PENTIUM: strProcLevel = "Intel Pentium" Case PROCESSOR_LEVEL_PENTIUMII: strProcLevel = "Intel Pentium Pro or Pentium II" End Select strProcRevision = "Model " & HiByte(tSYS.wProcessorRevision) & ", Stepping " & LoByte(tSYS.wProcessorRevision) With ptCPUInfo .lClockSpeed = GetCPUSpeed .lNumberOfProcessors = tSYS.dwNumberOfProcessors .lProcType = intProcType .strProcLevel = IIf(strProcLevel = "", "None", strProcLevel) .strProcRevision = IIf(strProcRevision = "", "None", strProcRevision) End With End Function Public Function HiByte(ByVal wParam As Integer) As Byte HiByte = (wParam And &HFF00&) \ (&H100) End Function Public Function LoByte(ByVal wParam As Integer) As Byte LoByte = wParam And &HFF& End Function Private Function GetCPUSpeed() As Long Dim hKey As Long Dim lClockSpeed As Long Dim strKey As String strKey = "HARDWARE\DESCRIPTION\System\CentralProcessor\0" Call RegOpenKey(HKEY_LOCAL_MACHINE, strKey, hKey) Call RegQueryValueEx(hKey, "~MHz", 0, 0, lClockSpeed, 4) Call RegCloseKey(hKey) GetCPUSpeed = lClockSpeed End Function
I'll make it to work on Win95/98 when I come back home.Code:Private Sub Command1_Click() Dim tCPU As udtCPU Call GetCPUInfo(tCPU) List1.AddItem "CPU Type: " & tCPU.lProcType List1.AddItem "Number ofCPUs: " & tCPU.lNumberOfProcessors List1.AddItem "CPU Level: " & tCPU.strProcLevel List1.AddItem "CPU Revision: " & tCPU.strProcRevision List1.AddItem "CPU Speed (Approx): " & tCPU.lClockSpeed End Sub
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819




Reply With Quote