QB64 Phoenix Edition
CPU Type and Speed - Printable Version

+- QB64 Phoenix Edition (https://staging.qb64phoenix.com)
+-- Forum: Chatting and Socializing (https://staging.qb64phoenix.com/forumdisplay.php?fid=11)
+--- Forum: General Discussion (https://staging.qb64phoenix.com/forumdisplay.php?fid=2)
+--- Thread: CPU Type and Speed (/showthread.php?tid=1735)

Pages: 1 2


CPU Type and Speed - TerryRitchie - 06-07-2023

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?


RE: CPU Type and Speed - mnrvovrfc - 06-07-2023

What a shame the author of "inxi" is such a rear-end about supporting Windows. I rather like the utility, but not its author. Angry

Not all Linux distros have it, however. Windows should be able to give something similar through Power Shell. I miss Balderdash around here.

Happily, there is weird stuff like this:

https://github.com/AlexFlipnote/neofetch-win

But it could be a chore to pick up the text from a visual stunt like that. "inxi" does more like a military-style report.


RE: CPU Type and Speed - Ultraman - 06-07-2023

I'm sure I could find you some code for this in Win32 API. If I remember to check, I will.


RE: CPU Type and Speed - SMcNeill - 06-07-2023

I think I've did this somewhere before.  Let me see if I can dig it up in a bit.  Wink


RE: CPU Type and Speed - SMcNeill - 06-07-2023

https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsysteminfo?redirectedfrom=MSDN <-- This is what you need, IIRC


RE: CPU Type and Speed - Ultraman - 06-09-2023

@TerryRitchie

Here you go.

Code: (Select All)
Option Explicit
$NoPrefix
$Console:Only

'$Include:'WinReg.BI'

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'
[Image: image.png]
I divided by 1,000 because the value is in MHz, not GHz


RE: CPU Type and Speed - TerryRitchie - 06-09-2023

(06-09-2023, 03:35 PM)Ultraman Wrote: @TerryRitchie

Here you go.

Code: (Select All)
Option Explicit
$NoPrefix
$Console:Only

'$Include:'WinReg.BI'

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'
[Image: image.png]
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.


RE: CPU Type and Speed - Ultraman - 06-09-2023

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.


RE: CPU Type and Speed - TerryRitchie - 06-09-2023

(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?


RE: CPU Type and Speed - Ultraman - 06-09-2023

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

'$Include:'WinReg.BM'


[Image: image.png]