CPU Speed

  • Thread starter Thread starter Claudio Di Flumeri
  • Start date Start date
C

Claudio Di Flumeri

Is there a way to get the CPU speed (in Mhz) without using WMI? I need to
include this functionality in a program that have to work also in Windows 98
and I don't want to distributeWMI apart.
 
Hi,

It is in the registry

Dim myReg As RegistryKey = Registry.LocalMachine

Dim MyRegKey As RegistryKey

Dim MyVal As String

MyRegKey =
myReg.OpenSubKey("HARDWARE\DESCRIPTION\SYSTEM\CentralProcessor\0")

MyVal = MyRegKey.GetValue("~Mhz")

MyRegKey.Close()

txtRegistry.Text = String.Format("CPU Speed {0}", MyVal)



Ken
 
It's exactly what I do now, but unfortunately that key is not always present
in Windows 98
 
you could calculate it, im not sure of the exact algoritm, but if you count
how many loops you can do in a certain period of time you can determin the
frequency of the clock in the system

like in one second, how many for loops can you do at CPU process usaged 100%
take that divide it out, figure out the number of processes that occured
then something else and that equals your speed in MHz.. there is some
documents on calculating MHz speeds on google if you search for it.
 
here is a small assembler snippit I used a few years ago. I don't know how to
compile it in VS, but it should be possible to compile this in C++ as a dll and then
call the dll from VB.NET.

JackRazz



..586p
..Model Flat ,StdCall
UNICODE=0
Extrn _wsprintfA : near
include w32.inc

..data

capt db 'CPU Test',0
format db 'CPU Speed = %lu Mhz',0
buffer db 30 dup (0)

..code

main:
xor eax,eax
rdtsc
mov ebx,eax
call Sleep, 1000
rdtsc
sub eax,ebx
sub eax,8
xor edx,edx
mov ecx,1000000
div ecx
call _wsprintfA, offset buffer, offset format, eax
call MessageBoxA, 0 ,offset buffer, offset capt, 0
call ExitProcess , 0

end main





| Is there a way to get the CPU speed (in Mhz) without using WMI? I need to
| include this functionality in a program that have to work also in Windows 98
| and I don't want to distributeWMI apart.
|
|
 
Back
Top