Error in some computers when trying to capture the voltage of the processor by WMI

0

On only a few computers when running my hardware specification program, it reports an error on line 155.

public static String voltage()
            {
                String Ic = String.Empty;
                foreach (var item in new ManagementObjectSearcher("Select from Win32_Processor").Get())
            {
                   Ic = (decimal.Parse(item["CurrentVoltage"].ToString()) / 10).ToString() + " v";
                    if(Ic == "0")
                    {
                        return "~";
                    }
                }
                return Ic;
            }
  

Line 155 below.

Ic = (decimal.Parse(item["CurrentVoltage"].ToString()) / 10).ToString() + " v";

And it prevents my program from running normally but it is only on some computers, the program generally runs without errors.

    
asked by anonymous 01.12.2015 / 15:46

0 answers