tip Posted October 27, 2008 Posted October 27, 2008 (edited) I spend sometime to find a script which gives CPU Name, Clock Speed and Number of Cores but I couldn't find anything. So I've learned how it can be done. Although it is a very simple script I'm posting it, hoping people to find it easier then I did ... Plus I'm using 2 different ways to obtain information. Second one can be useful when you don't want to wait 3-10 seconds. _CpuInfo function uses WMI objects and takes some time to return the wanted information. (This takes 4 seconds on my PC) _FasterCpuInfo uses Reg Entries(This one takes 0 milliseconds ) _MemInfo Returns Total Physical Memory. expandcollapse popupFunc _CpuInfo() $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Cpu_Output="" $Cpu_Core = 0 $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Cpu_Output = $Cpu_Output & "Architecture: " & $objItem.Architecture & @CRLF $Cpu_Output = $Cpu_Output & "Max Clock Speed: " & $objItem.MaxClockSpeed & @CRLF $Cpu_Output = $Cpu_Output & "Name: " & $objItem.Name & @CRLF $Cpu_Name = $objItem.Name $Cpu_Clock = $objItem.MaxClockSpeed $Cpu_Arch = $objItem.Architecture $Cpu_Core += 1 Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Processor" ) Endif EndFunc Func _FasterCpuInfo() $Cpu_Core = 0 For $i= 1 to 1000 $Temp = RegEnumKey("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\", $i) If @error <> 0 then ExitLoop $Cpu_Core += 1 Next $Cpu_Name = RegRead ("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0","ProcessorNameString") $Cpu_Clock = RegRead ("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0","~MHz") EndFunc Func _MemInfo() $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Mem_Output="" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_LogicalMemoryConfiguration", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Mem_Output = $objItem.TotalPhysicalMemory Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_LogicalMemoryConfiguration" ) Endif Return Int($Mem_Output/1024) EndFunc Func _Timer_Compare() $Timer = TimerInit() _CpuInfo() $CpuInfo_Timer = "_CpuInfo takes " & Int(TimerDiff($Timer)) & " milliseconds" $timer = 0 $Timer = TimerInit() _FasterCpuInfo() $FasterCpuInfo_Timer = "_FasterCpuInfo takes " & Int(TimerDiff($Timer)) & " milliseconds" $timer = 0 $Timer = TimerInit() _MemInfo() $MemInfo_Timer = "_MemInfo takes " & Int(TimerDiff($Timer)) & " milliseconds" MsgBox(64,"Timers",$CpuInfo_Timer & @CRLF & @CRLF & $FasterCpuInfo_Timer & @CRLF & @CRLF & $MemInfo_Timer) EndFunc Timer_Compare() I'm not sure whether _FasterCPUInfo function is a valid way for everyone or just working on my PC. So I will be glad if you give me some feedback or share your knowledge about it... Enjoy Sincerely Tip P.S.: There is a good chance that similar script exists already on the forum... If it is so, know that I don't mean to be rude I just couldn't find it... Edited October 27, 2008 by tip [center]MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.[/center]
ironmankho Posted October 27, 2008 Posted October 27, 2008 (edited) it is great script . i have no idea why people no create something new !!!! why repeat old story ? Edited October 27, 2008 by ironmankho
Emiel Wieldraaijer Posted October 27, 2008 Posted October 27, 2008 Hi Tip.. you did well but : Fastest way to get the number of cores -> EnvGet("NUMBER_OF_PROCESSORS")Example Msgbox(0, "Number Of Cores", EnvGet("NUMBER_OF_PROCESSORS"))Some computerinfo scriptshttp://www.autoitscript.com/forum/index.ph...amp;hl=CompInfohttp://www.autoitscript.com/forum/index.ph...amp;hl=CompInfoand Try -> MemGetStats ( ) Returns a seven-element array containing the memory information:$array[0] = Memory Load (Percentage of memory in use)$array[1] = Total physical RAM$array[2] = Available physical RAM$array[3] = Total Pagefile$array[4] = Available Pagefile$array[5] = Total virtual$array[6] = Available virtualAll memory sizes are in kilobytes.Best regards,Emiel Best regards,Emiel Wieldraaijer
tip Posted October 27, 2008 Author Posted October 27, 2008 So reading cpu information from registry is a valid vay ... @Emiel Thank you Emiel. [center]MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.[/center]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now