468,484 Members | 2,009 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,484 developers. It's quick & easy.

CPU Speed

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.
Nov 20 '05 #1
8 788
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\Cent ralProcessor\0")

MyVal = MyRegKey.GetValue("~Mhz")

MyRegKey.Close()

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

Ken

--------------------

"Claudio Di Flumeri" <cl***********@mtgc.net> wrote in message
news:c4*************@ID-198343.news.uni-berlin.de...
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.

Nov 20 '05 #2
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\Cent ralProcessor\0")

MyVal = MyRegKey.GetValue("~Mhz")

MyRegKey.Close()

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

Ken

--------------------

"Claudio Di Flumeri" <cl***********@mtgc.net> wrote in message
news:c4*************@ID-198343.news.uni-berlin.de...
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.

Nov 20 '05 #3
It's exactly what I do now, but unfortunately that key is not always present
in Windows 98
"Ken Tucker [MVP]" <vb***@bellsouth.net> ha scritto nel messaggio
news:eZ**************@TK2MSFTNGP11.phx.gbl...
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\Cent ralProcessor\0")

MyVal = MyRegKey.GetValue("~Mhz")

MyRegKey.Close()

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

Ken

--------------------

"Claudio Di Flumeri" <cl***********@mtgc.net> wrote in message
news:c4*************@ID-198343.news.uni-berlin.de...
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.



Nov 20 '05 #4
It's exactly what I do now, but unfortunately that key is not always present
in Windows 98
"Ken Tucker [MVP]" <vb***@bellsouth.net> ha scritto nel messaggio
news:eZ**************@TK2MSFTNGP11.phx.gbl...
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\Cent ralProcessor\0")

MyVal = MyRegKey.GetValue("~Mhz")

MyRegKey.Close()

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

Ken

--------------------

"Claudio Di Flumeri" <cl***********@mtgc.net> wrote in message
news:c4*************@ID-198343.news.uni-berlin.de...
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.



Nov 20 '05 #5
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.
"Claudio Di Flumeri" <cl***********@mtgc.net> wrote in message
news:c4*************@ID-198343.news.uni-berlin.de...
It's exactly what I do now, but unfortunately that key is not always present in Windows 98
"Ken Tucker [MVP]" <vb***@bellsouth.net> ha scritto nel messaggio
news:eZ**************@TK2MSFTNGP11.phx.gbl...
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\Cent ralProcessor\0")

MyVal = MyRegKey.GetValue("~Mhz")

MyRegKey.Close()

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

Ken

--------------------

"Claudio Di Flumeri" <cl***********@mtgc.net> wrote in message
news:c4*************@ID-198343.news.uni-berlin.de...
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.



Nov 20 '05 #6
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.
"Claudio Di Flumeri" <cl***********@mtgc.net> wrote in message
news:c4*************@ID-198343.news.uni-berlin.de...
It's exactly what I do now, but unfortunately that key is not always present in Windows 98
"Ken Tucker [MVP]" <vb***@bellsouth.net> ha scritto nel messaggio
news:eZ**************@TK2MSFTNGP11.phx.gbl...
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\Cent ralProcessor\0")

MyVal = MyRegKey.GetValue("~Mhz")

MyRegKey.Close()

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

Ken

--------------------

"Claudio Di Flumeri" <cl***********@mtgc.net> wrote in message
news:c4*************@ID-198343.news.uni-berlin.de...
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.



Nov 20 '05 #7
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

"Claudio Di Flumeri" <cl***********@mtgc.net> wrote in message
news:c4*************@ID-198343.news.uni-berlin.de...
| 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.
|
|
Nov 20 '05 #8
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

"Claudio Di Flumeri" <cl***********@mtgc.net> wrote in message
news:c4*************@ID-198343.news.uni-berlin.de...
| 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.
|
|
Nov 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Yang Li Ke | last post: by
8 posts views Thread by Rob Ristroph | last post: by
34 posts views Thread by Jacek Generowicz | last post: by
28 posts views Thread by Maboroshi | last post: by
52 posts views Thread by Neuruss | last post: by
7 posts views Thread by YAZ | last post: by
6 posts views Thread by Ham | last post: by
6 posts views Thread by Jassim Rahma | last post: by
11 posts views Thread by kyosohma | last post: by
2 posts views Thread by gieforce | last post: by
reply views Thread by theflame83 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.