A while back I could have sworn I saw someone post code that identified the CPU and speed using a Declare Library but I can't find it. Furthermore, I would have saved something like that in my box of goodies but I can't find that either?? Is my age finally messing with my brain or did I in fact see this code recently?
New to QB64pe? Visit the QB64 tutorial to get started. QB64 Tutorial
Dim As Unsigned Long procSpeed
Dim As String procName
If ReadREG_SZ(HKEY_LOCAL_MACHINE, "HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString", procName) = REG_TRUE Then
Print "Processor:", procName
End If
If ReadREG_DWORD(HKEY_LOCAL_MACHINE, "HARDWARE\DESCRIPTION\System\CentralProcessor\0", "~MHz", procSpeed) = REG_TRUE Then
Print "Processor Speed:", procSpeed / 1000; "GHz"
End If
'$Include:'WinReg.BM'
I divided by 1,000 because the value is in MHz, not GHz
Dim As Unsigned Long procSpeed
Dim As String procName
If ReadREG_SZ(HKEY_LOCAL_MACHINE, "HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString", procName) = REG_TRUE Then
Print "Processor:", procName
End If
If ReadREG_DWORD(HKEY_LOCAL_MACHINE, "HARDWARE\DESCRIPTION\System\CentralProcessor\0", "~MHz", procSpeed) = REG_TRUE Then
Print "Processor Speed:", procSpeed / 1000; "GHz"
End If
'$Include:'WinReg.BM'
I divided by 1,000 because the value is in MHz, not GHz
Excellent! Thank you. It's as simple as looking in the registry for the info. Much easier than I imagined.
New to QB64pe? Visit the QB64 tutorial to get started. QB64 Tutorial
(06-09-2023, 05:05 PM)Ultraman Wrote: Yep! It's quite easy to find the information. You can use what I sent and tweak for other information you might want from the registry.
Yep, that thought instantly came to my mind.
Where did WinReg.BI and WinReg.BM come from? Did you create these? Any documentation for them?
New to QB64pe? Visit the QB64 tutorial to get started. QB64 Tutorial
So, if we wanted to also include the motherboard manufacturer, BIOS version, and computer model name:
Code: (Select All)
Option Explicit
$NoPrefix
$Console:Only
'$Include:'WinReg.BI'
Dim As Unsigned Long procSpeed, biosMajor, BiosMinor
Dim As String procName, BiosVersion, systemVersion, systemManufacturer
If ReadREG_SZ(HKEY_LOCAL_MACHINE, "HARDWARE\DESCRIPTION\System\CentralProcessor\0", "ProcessorNameString", procName) = REG_TRUE Then
Print "Processor: "; procName
End If
If ReadREG_DWORD(HKEY_LOCAL_MACHINE, "HARDWARE\DESCRIPTION\System\CentralProcessor\0", "~MHz", procSpeed) = REG_TRUE Then
Print "Processor Speed: "; procSpeed / 1000; "GHz"
End If
If ReadREG_SZ(HKEY_LOCAL_MACHINE, "HARDWARE\DESCRIPTION\System\BIOS", "SystemManufacturer", systemManufacturer) = REG_TRUE Then
Print "System Manufacturer: "; systemManufacturer
End If
If ReadREG_SZ(HKEY_LOCAL_MACHINE, "HARDWARE\DESCRIPTION\System\BIOS", "SystemVersion", systemVersion) = REG_TRUE Then
Print "System Version: "; systemVersion
End If
If ReadREG_DWORD(HKEY_LOCAL_MACHINE, "HARDWARE\DESCRIPTION\System\BIOS", "BiosMajorRelease", biosMajor) = REG_TRUE Then
If ReadREG_DWORD(HKEY_LOCAL_MACHINE, "HARDWARE\DESCRIPTION\System\BIOS", "BiosMinorRelease", BiosMinor) = REG_TRUE Then
Print Using "BIOS Version: ##_.##"; biosMajor; BiosMinor
End If
End If