Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

help with code, displaying WMI info in a text box on a windows form.

$
0
0

I would love to have some help with my application, I have been trying for multiple hours to get the results of a foreach management object query into a text box but nothing I do seems to work. Thanks, here is my code.

 

 public class Temperature
        {
            public double CurrentValue { get; set; }
            public string InstanceName { get; set; }
            public static List<Temperature> Temperatures
            {
                get
                {
                    List<Temperature> result = new List<Temperature>();
                    ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"root\WMI", "SELECT * FROM MSAcpi_ThermalZoneTemperature");
                    foreach (ManagementObject obj in searcher.Get())
                
                        {
                            Double temp = Convert.ToDouble(obj["CurrentTemperature"].ToString());
                            temp = (temp - 2732) / 10.0;

                            result.Add(new Temperature { CurrentValue = temp });
                            

                        }
                        return result;
                    }

                }
            }

Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>