How to determine the hardware (CPU and RAM) on a machine?

前端 未结 13 1085
长发绾君心
长发绾君心 2020-12-31 03:29

I\'m working on a cross platform profiling suite, and would like to add information about the machine\'s CPU (architecture/clock speed/cores) and RAM(total) to the report of

13条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-31 03:42

    I've written some code which uses the WMI service to get the Max Clock Speed, I know it's VB.net but it shows the idea:

    ''' 
    ''' Use WMI to get the Clock Speed in Hz
    ''' 
    Public Function GetMaxClockSpeedInHz() As Double
        Dim manObj = New ManagementObject("Win32_Processor.DeviceID='CPU0'")
        manObj.Get()
        GetMaxClockSpeedInHz = Convert.ToInt32(manObj.Properties("MaxClockSpeed").Value)
    End Function
    

    Win32_OperatingSystem reference : http://msdn.microsoft.com/en-us/library/Aa394239

    WMI Reference : http://msdn.microsoft.com/en-us/library/aa394572(v=VS.85).aspx

提交回复
热议问题