Reading Device Manager's Property Fields in Windows 7/8

前端 未结 3 1269
野性不改
野性不改 2021-02-09 17:42

I am developing a windows application which gives the field details --> X.

Where X is -->

Right Click My Computer >

    Properties >

                


        
3条回答
  •  你的背包
    2021-02-09 18:30

    It's quite easy to get the hardware information using ManagementObjectCollection.

    For instance to get all properties and values from the PC processor

    var win32DeviceClassName = "win32_processor";
                var query = string.Format("select * from {0}", win32DeviceClassName);
    
                using (var searcher = new ManagementObjectSearcher(query))
                {
                    ManagementObjectCollection  objectCollection = searcher.Get();
    
                    foreach (ManagementBaseObject managementBaseObject in objectCollection)
                    {
                        foreach (PropertyData propertyData in managementBaseObject.Properties)
                        {
                            Console.WriteLine("Property:  {0}, Value: {1}", propertyData.Name, propertyData.Value);
                        }
                    }
    
    
    
                }
    

    The full list of WIN32 class name is available at http://msdn.microsoft.com/en-us/library/aa394084%28v=VS.85%29.aspx

    Cheers.

提交回复
热议问题