Skip to content

Commit

Permalink
Specify culture for float conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Rem0o committed May 10, 2022
1 parent 7b2e2a5 commit df4015c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions HWInfoRegistry.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

namespace FanControl.HWInfo
{
internal class HWInfoRegistry: IDisposable
internal class HWInfoRegistry : IDisposable
{
private static CultureInfo _format = new CultureInfo("en-us");

const string SENSOR_REGISTRY_NAME = "Sensor";
const string LABEL_REGISTRY_NAME = "Label";
const string VALUE_REGISTRY_NAME = "Value";
Expand Down Expand Up @@ -59,7 +62,7 @@ public HWInfoPluginSensor[] GetSensors()

internal bool UpdateValues(HWInfoPluginSensor[] sensors)
{
foreach(var sensor in sensors)
foreach (var sensor in sensors)
{
object valueRaw = _key.GetValue(VALUE_RAW_REGISTRY_NAME + sensor.Index);

Expand All @@ -68,7 +71,7 @@ internal bool UpdateValues(HWInfoPluginSensor[] sensors)
return false;
}

sensor.Value = float.Parse((String)valueRaw);
sensor.Value = float.TryParse((string)valueRaw, NumberStyles.Float, _format, out float res) ? res : default(float?);
}

return true;
Expand Down

0 comments on commit df4015c

Please sign in to comment.