By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,168 Members | 2,511 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,168 IT Pros & Developers. It's quick & easy.

Detecting CPU speed

P: n/a
Hi all.

How can I detect CPU speed (in MHz) with .NET (VB or C#)?

There are some DLLs or registry tricks, but is there a way detecting
it using dotNet's abilities or windows API?

thnx in advance.
Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Cor
Hi MSDousti,

Have a look at managementobject Win32_Processor

I hope this helps?

Cor
How can I detect CPU speed (in MHz) with .NET (VB or C#)?
There are some DLLs or registry tricks, but is there a way detecting
it using dotNet's abilities or windows API?
thnx in advance.

Nov 20 '05 #2

P: n/a
Hi,

Add a reference to system.management.dll.

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Processor")

moReturn = moSearch.Get

For Each mo In moReturn

Dim strout As String = String.Format("{0} - {1}", mo("Name"),
mo("CurrentClockSpeed"))

Debug.WriteLine(strout)

Next

Ken

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

"MSDousti" <MS******@myrealbox.com> wrote in message
news:bf**************************@posting.google.c om...
Hi all.

How can I detect CPU speed (in MHz) with .NET (VB or C#)?

There are some DLLs or registry tricks, but is there a way detecting
it using dotNet's abilities or windows API?

thnx in advance.

Nov 20 '05 #3

P: n/a
KS
I get an exception

An unhandled exception of type 'System.Management.ManagementException'
occurred in system.management.dll

and a green marked line "Next" in the FOR-NEXT loop - why ?

KS, Denmark
"Ken Tucker [MVP]" <vb***@bellsouth.net> skrev i en meddelelse
news:uc**************@TK2MSFTNGP10.phx.gbl...
Hi,

Add a reference to system.management.dll.

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Processor")

moReturn = moSearch.Get

For Each mo In moReturn

Dim strout As String = String.Format("{0} - {1}", mo("Name"),
mo("CurrentClockSpeed"))

Debug.WriteLine(strout)

Next

Ken

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

"MSDousti" <MS******@myrealbox.com> wrote in message
news:bf**************************@posting.google.c om...
Hi all.

How can I detect CPU speed (in MHz) with .NET (VB or C#)?

There are some DLLs or registry tricks, but is there a way detecting
it using dotNet's abilities or windows API?

thnx in advance.


Nov 20 '05 #4

P: n/a
Put in a reference to System.Management (not .dll).
"KS" <ke************@os.dk> wrote in message
news:uR***************@TK2MSFTNGP11.phx.gbl...
I get an exception

An unhandled exception of type 'System.Management.ManagementException'
occurred in system.management.dll

and a green marked line "Next" in the FOR-NEXT loop - why ?

KS, Denmark
"Ken Tucker [MVP]" <vb***@bellsouth.net> skrev i en meddelelse
news:uc**************@TK2MSFTNGP10.phx.gbl...
Hi,

Add a reference to system.management.dll.

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Processor")

moReturn = moSearch.Get

For Each mo In moReturn

Dim strout As String = String.Format("{0} - {1}", mo("Name"),
mo("CurrentClockSpeed"))

Debug.WriteLine(strout)

Next

Ken

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

"MSDousti" <MS******@myrealbox.com> wrote in message
news:bf**************************@posting.google.c om...
Hi all.

How can I detect CPU speed (in MHz) with .NET (VB or C#)?

There are some DLLs or registry tricks, but is there a way detecting
it using dotNet's abilities or windows API?

thnx in advance.



Nov 20 '05 #5

P: n/a
KS
I'm confused !

Ken writes: "Add a reference to system.management.dll."

you writes: "Put in a reference to System.Management (not .dll)."

and I only have "System.Management" - but it IS in fact a dll !

What can I do ?

KS, Denmark


"Lloyd Sheen" <sq*******************@tostopspamhotmail.com> skrev i en
meddelelse
news:fW*******************@news01.bloor.is.net.cab le.rogers.com...
Put in a reference to System.Management (not .dll).
"KS" <ke************@os.dk> wrote in message
news:uR***************@TK2MSFTNGP11.phx.gbl...
I get an exception

An unhandled exception of type 'System.Management.ManagementException'
occurred in system.management.dll

and a green marked line "Next" in the FOR-NEXT loop - why ?

KS, Denmark
"Ken Tucker [MVP]" <vb***@bellsouth.net> skrev i en meddelelse
news:uc**************@TK2MSFTNGP10.phx.gbl...
Hi,

Add a reference to system.management.dll.

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Processor")

moReturn = moSearch.Get

For Each mo In moReturn

Dim strout As String = String.Format("{0} - {1}", mo("Name"),
mo("CurrentClockSpeed"))

Debug.WriteLine(strout)

Next

Ken

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

"MSDousti" <MS******@myrealbox.com> wrote in message
news:bf**************************@posting.google.c om...
> Hi all.
>
> How can I detect CPU speed (in MHz) with .NET (VB or C#)?
>
> There are some DLLs or registry tricks, but is there a way detecting
> it using dotNet's abilities or windows API?
>
> thnx in advance.



Nov 20 '05 #6

P: n/a
KS
Ohhhhh - I found out myself !

I had some extra " in

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Processor")

KS, Denmark

"KS" <ke************@os.dk> skrev i en meddelelse
news:u%******************@tk2msftngp13.phx.gbl...
I'm confused !

Ken writes: "Add a reference to system.management.dll."

you writes: "Put in a reference to System.Management (not .dll)."

and I only have "System.Management" - but it IS in fact a dll !

What can I do ?

KS, Denmark


"Lloyd Sheen" <sq*******************@tostopspamhotmail.com> skrev i en
meddelelse
news:fW*******************@news01.bloor.is.net.cab le.rogers.com...
Put in a reference to System.Management (not .dll).
"KS" <ke************@os.dk> wrote in message
news:uR***************@TK2MSFTNGP11.phx.gbl...
I get an exception

An unhandled exception of type 'System.Management.ManagementException'
occurred in system.management.dll

and a green marked line "Next" in the FOR-NEXT loop - why ?

KS, Denmark
"Ken Tucker [MVP]" <vb***@bellsouth.net> skrev i en meddelelse
news:uc**************@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> Add a reference to system.management.dll.
>
> Dim moReturn As Management.ManagementObjectCollection
>
> Dim moSearch As Management.ManagementObjectSearcher
>
> Dim mo As Management.ManagementObject
>
> moSearch = New Management.ManagementObjectSearcher("Select * from
> Win32_Processor")
>
> moReturn = moSearch.Get
>
> For Each mo In moReturn
>
> Dim strout As String = String.Format("{0} - {1}", mo("Name"),
> mo("CurrentClockSpeed"))
>
> Debug.WriteLine(strout)
>
> Next
>
>
>
> Ken
>
> ---------------------------
>
> "MSDousti" <MS******@myrealbox.com> wrote in message
> news:bf**************************@posting.google.c om...
> > Hi all.
> >
> > How can I detect CPU speed (in MHz) with .NET (VB or C#)?
> >
> > There are some DLLs or registry tricks, but is there a way detecting > > it using dotNet's abilities or windows API?
> >
> > thnx in advance.
>
>



Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.