To get the cpu speed in C# and VB.NET you can use the following snippet.
Sample C#
public uint GetCpuSpeed() { var managementObject = new ManagementObject("Win32_Processor.DeviceID='CPU0'"); var speed = (uint)(managementObject["CurrentClockSpeed"]); managementObject.Dispose(); return speed; }
Sample VB.NET
Public Function GetCpuSpeed() As UInteger Dim managementObject = New ManagementObject("Win32_Processor.DeviceID='CPU0'") Dim speed As UInteger = CUInt(managementObject("CurrentClockSpeed")) managementObject.Dispose() Return speed End Function
RT @CodeSnippetsNET: How to get the cpu speed in .NET http://t.co/qPjJvCKR9P #csharp #vb #dotnet #programming #code #coding