CPU Type and Speed
#1
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?
Software and cathedrals are much the same — first we build them, then we pray.
QB64 Tutorial
Reply
#2
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.
Reply
#3
I'm sure I could find you some code for this in Win32 API. If I remember to check, I will.
Schuwatch!
Yes, it's me. Now shut up.
Reply
#4
I think I've did this somewhere before.  Let me see if I can dig it up in a bit.  Wink
Reply
#5
https://learn.microsoft.com/en-us/window...dfrom=MSDN <-- This is what you need, IIRC
Reply
#6
@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


Attached Files
.bi   WinReg.BI (Size: 450 bytes / Downloads: 81)
.bm   WinReg.BM (Size: 32.29 KB / Downloads: 85)
Schuwatch!
Yes, it's me. Now shut up.
Reply
#7
(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.
Software and cathedrals are much the same — first we build them, then we pray.
QB64 Tutorial
Reply
#8
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.
Schuwatch!
Yes, it's me. Now shut up.
Reply
#9
(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?
Software and cathedrals are much the same — first we build them, then we pray.
QB64 Tutorial
Reply
#10
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]
Schuwatch!
Yes, it's me. Now shut up.
Reply




Users browsing this thread: 2 Guest(s)