Jump to content

CPU-Z through WinAPI. Dreams?


Entropy
 Share

Recommended Posts

Hi, there!

I have a fairy idea for my app: get a current CPU frequency.

The only way i found is take info from WMI (Win32_Processor) object. But trouble is CurrentClockSpeed and MaxClockSpeed is the same.

I don't know what is a problem, but seems this object does not collect info in Speed Step or Cool'n'Queit frequency decreasing issue.

It is possible to measure current frequency, through RDMSR, but it doesn't works. It returns the base frequency.

Any ideas?

Link to comment
Share on other sites

Using CPUZ's ability to take in a parameter to generate a report file, I created this script for you:

#include <file.au3>
Run("cpuz.exe -txt=" & @TempDir & "Report")
$linecount = _FileCountLines(@TempDir & "Report.txt")

For $i = 1 To $linecount Step 1
    $line = FileReadLine(@TempDir & "Report.txt", $i)
    If StringInStr($line, "Core Speed") Then
        $correctLine = $line
        ExitLoop
    EndIf
Next

FileDelete(@TempDir & "Report.txt")

$formattedLine = StringStripWS($correctLine, 8)
$finalString = StringTrimLeft($formattedLine, 9)

MsgBox(0, "", "Your Core Speed is: " & $finalString)
Edited by sleepydvdr

#include <ByteMe.au3>

Link to comment
Share on other sites

Using CPUZ's ability to take in a parameter to generate a report file, I created this script for you:

#include <file.au3>
Run("cpuz.exe -txt=" & @TempDir & "Report")
$linecount = _FileCountLines(@TempDir & "Report.txt")

For $i = 1 To $linecount Step 1
    $line = FileReadLine(@TempDir & "Report.txt", $i)
    If StringInStr($line, "Core Speed") Then
        $correctLine = $line
        ExitLoop
    EndIf
Next

FileDelete(@TempDir & "Report.txt")

$formattedLine = StringStripWS($correctLine, 8)
$finalString = StringTrimLeft($formattedLine, 9)

MsgBox(0, "", "Your Core Speed is: " & $finalString)

Brilliant idea! Thanks!

The only thing, i worry about using this script is to trace cpu frequency in "real time".

What do you think?

Link to comment
Share on other sites

I didn't realize you wanted to monitor it in real time. In that case, my suggestion would not be efficient. I did some reading on the subject. The post by Mark below has some good info:

http://forums.extremeoverclocking.com/t348585.html

I don't think I will be able to help you any more. It is out of my league. Good luck.

Edited by sleepydvdr

#include <ByteMe.au3>

Link to comment
Share on other sites

Can you try this:

;coded by UEZ build 2011-12-08
Global $exit = False
Global $oErrorHandler = ObjEvent("AutoIt.Error", "ObjErrorHandler")

$hGUI = GUICreate("WMI CPU / Memory Monitor", 385, 140, -1, -1)
GUISetFont(8, 400, 0, "Arial")
$idLabel_CPU = GUICtrlCreateLabel("CPU", 58, 12, 24, 18)
$idLabel_Current = GUICtrlCreateLabel("Current Speed", 11, 36, 77, 18)
$idLabel_Max = GUICtrlCreateLabel("Max Speed", 25, 60, 58, 18)
$idLabel_CPULoad = GUICtrlCreateLabel("CPU Load", 31, 84, 78, 18)
$idLabel_MemAvailable = GUICtrlCreateLabel("Available Mem", 7, 110, 78, 18)

$idInput_CPU = GUICtrlCreateInput("", 88, 8, 285, 22)
$idInput_Current = GUICtrlCreateInput("0", 88, 32, 285, 22)
$idInput_Max = GUICtrlCreateInput("0", 88, 56, 285, 22)
$idInput_CPULoad = GUICtrlCreateInput("0", 88, 80, 285, 22)
$idInput_MemAvailable = GUICtrlCreateInput("0", 88, 106, 285, 22)
GUISetState(@SW_SHOW)

WMI_GetCPUMemInfo()
Exit

Func WMI_GetCPUMemInfo($host = "localhost") ;coded by UEZ 2011
    Local $colItems
    Local $objWMIService = ObjGet("winmgmts:.rootcimv2")
    Local $objRefresher = ObjCreate("WbemScripting.SWbemRefresher")
    Local $colItems = $objRefresher.AddEnum($objWMIService, "Win32_PerfFormattedData_PerfOS_Memory").ObjectSet
    Local $colItems2 = $objRefresher.AddEnum($objWMIService, "Win32_Processor").ObjectSet
    $objRefresher.Refresh
    For $objItem In $colItems2
        GUICtrlSetData($idInput_CPU, StringStripWS($objItem.Name, 7))
        GUICtrlSetData($idInput_Current, $objItem.CurrentClockSpeed & " MHz")
        GUICtrlSetData($idInput_Max, $objItem.MaxClockSpeed & " MHz")
        GUICtrlSetData($idInput_CPULoad, $objItem.LoadPercentage & "%")
    Next
    For $objItem In $colItems
        GUICtrlSetData($idInput_MemAvailable, $objItem.AvailableBytes & " Bytes / " & Round($objItem.AvailableBytes / 1024^2, 2) & " MB")
    Next
    Do
        $objRefresher.Refresh
        For $objItem In $colItems2
            GUICtrlSetData($idInput_Current, $objItem.CurrentClockSpeed & " MHz")
            GUICtrlSetData($idInput_CPULoad, $objItem.LoadPercentage & "%")
        Next
        For $objItem In $colItems
            GUICtrlSetData($idInput_MemAvailable, $objItem.AvailableBytes & " Bytes / " & Round($objItem.AvailableBytes / 1024^2, 2) & " MB")
        Next
    Until GUIGetMsg() = -3
EndFunc

Func ObjErrorHandler()
    ConsoleWrite(   "A COM Error has occured!" & @CRLF  & @CRLF & _
                                "err.description is: "    & @TAB & $oErrorHandler.description    & @CRLF & _
                                "err.windescription:"     & @TAB & $oErrorHandler & @CRLF & _
                                "err.number is: "         & @TAB & Hex($oErrorHandler.number, 8)  & @CRLF & _
                                "err.lastdllerror is: "   & @TAB & $oErrorHandler.lastdllerror   & @CRLF & _
                                "err.scriptline is: "     & @TAB & $oErrorHandler.scriptline     & @CRLF & _
                                "err.source is: "         & @TAB & $oErrorHandler.source         & @CRLF & _
                                "err.helpfile is: "       & @TAB & $oErrorHandler.helpfile       & @CRLF & _
                                "err.helpcontext is: "    & @TAB & $oErrorHandler.helpcontext & @CRLF _
                            )
EndFunc

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...