Posts: 1,190
Threads: 113
Joined: Apr 2022
Reputation:
102
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
Posts: 1,432
Threads: 58
Joined: Jul 2022
Reputation:
52
What a shame the author of "inxi" is such a rear-end about supporting Windows. I rather like the utility, but not its author.
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.
Posts: 68
Threads: 1
Joined: Apr 2023
Reputation:
2
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.
Posts: 2,964
Threads: 345
Joined: Apr 2022
Reputation:
274
I think I've did this somewhere before. Let me see if I can dig it up in a bit.
Posts: 2,964
Threads: 345
Joined: Apr 2022
Reputation:
274
Posts: 68
Threads: 1
Joined: Apr 2023
Reputation:
2
06-09-2023, 03:35 PM
(This post was last modified: 06-09-2023, 03:37 PM by Ultraman .)
@TerryRitchie
Here you go.
Code: (Select All)
Option Explicit
$NoPrefix
$Console :Only
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
I divided by 1,000 because the value is in MHz, not GHz
Attached Files
WinReg.BI (Size: 450 bytes / Downloads: 101)
WinReg.BM (Size: 32.29 KB / Downloads: 87)
Schuwatch!
Yes, it's me. Now shut up.
Posts: 1,190
Threads: 113
Joined: Apr 2022
Reputation:
102
(06-09-2023, 03:35 PM) Ultraman Wrote: @TerryRitchie
Here you go.
Code: (Select All)
Option Explicit
$NoPrefix
$Console :Only
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
I divided by 1,000 because the value is in MHz, not GHzExcellent! 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
Posts: 68
Threads: 1
Joined: Apr 2023
Reputation:
2
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.
Posts: 1,190
Threads: 113
Joined: Apr 2022
Reputation:
102
(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
Posts: 68
Threads: 1
Joined: Apr 2023
Reputation:
2
So, if we wanted to also include the motherboard manufacturer, BIOS version, and computer model name:
Code: (Select All)
Option Explicit
$NoPrefix
$Console :Only
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
Schuwatch!
Yes, it's me. Now shut up.