Detecting CPU speed

  • Thread starter Thread starter MSDousti
  • Start date Start date
M

MSDousti

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.
 
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
 
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
 
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" <[email protected]> skrev i en
meddelelse
 
Ohhhhh - I found out myself !

I had some extra " in

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

KS, Denmark
 
Back
Top