Determine operating system and processor type in C#

后端 未结 4 1956
谎友^
谎友^ 2021-02-05 21:03

I want to check what type of operating system i use and what kind of processor. this should be check on run time. i tried using

System.Environment.GetEnvironment         


        
4条回答
  •  执笔经年
    2021-02-05 21:49

    Look at the ManagementClass class: http://msdn.microsoft.com/en-us/library/system.management.managementclass.aspx

    var mgmt = new ManagementClass("Win32_OperatingSystem");
    foreach (ManagementObject mgmtObj in mgmt.GetInstances())
    {                
        // Just get first value.
        return mgmtObj[info.Information].ToString().Trim();
    }
    

提交回复
热议问题