M16 Fan fix for older BIOS only

This commit is contained in:
Serge
2023-09-24 12:23:31 +02:00
parent 8773e26219
commit 0fed74e069
3 changed files with 44 additions and 30 deletions

View File

@@ -7,7 +7,9 @@ public static class AppConfig
{
private static string configFile;
private static string? _model;
private static string? _bios;
private static Dictionary<string, object> config = new Dictionary<string, object>();
@@ -69,6 +71,34 @@ public static class AppConfig
return _model;
}
public static (string, string) GetBiosAndModel()
{
if (_bios is not null && _model is not null) return (_bios, _model);
using (ManagementObjectSearcher objSearcher = new ManagementObjectSearcher(@"SELECT * FROM Win32_BIOS"))
{
using (ManagementObjectCollection objCollection = objSearcher.Get())
{
foreach (ManagementObject obj in objCollection)
if (obj["SMBIOSBIOSVersion"] is not null)
{
string[] results = obj["SMBIOSBIOSVersion"].ToString().Split(".");
if (results.Length > 1)
{
_model = results[0];
_bios = results[1];
}
else
{
_model = obj["SMBIOSBIOSVersion"].ToString();
}
}
return (_bios, _model);
}
}
}
public static string GetModelShort()
{
string model = GetModel();
@@ -363,12 +393,21 @@ public static class AppConfig
public static bool IsFanScale()
{
return ContainsModel("GU604");
if (!ContainsModel("GU604")) return false;
try
{
var (bios, model) = GetBiosAndModel();
return (Int32.Parse(bios) < 312);
} catch
{
return false;
}
}
public static bool IsFanRequired()
{
return ContainsModel("GA402X") || ContainsModel("G513") || ContainsModel("G713R");
return ContainsModel("GA402X") || ContainsModel("G513") || ContainsModel("G713R") || ContainsModel("G713P");
}
public static bool IsPowerRequired()

View File

@@ -15,7 +15,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.125</AssemblyVersion>
<AssemblyVersion>0.126</AssemblyVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@@ -13,8 +13,8 @@ namespace GHelper
const int DRIVER_NEWER = 1;
//static int rowCount = 0;
static string model;
static string bios;
static string model;
static int updatesCount = 0;
private static long lastUpdate;
@@ -33,7 +33,7 @@ namespace GHelper
if (!force && (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastUpdate) < 5000)) return;
lastUpdate = DateTimeOffset.Now.ToUnixTimeMilliseconds();
InitBiosAndModel();
(bios, model) = AppConfig.GetBiosAndModel();
updatesCount = 0;
labelUpdates.ForeColor = colorEco;
@@ -116,31 +116,6 @@ namespace GHelper
}
}
private string InitBiosAndModel()
{
using (ManagementObjectSearcher objSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_BIOS"))
{
using (ManagementObjectCollection objCollection = objSearcher.Get())
{
foreach (ManagementObject obj in objCollection)
if (obj["SMBIOSBIOSVersion"] is not null)
{
string[] results = obj["SMBIOSBIOSVersion"].ToString().Split(".");
if (results.Length > 1)
{
model = results[0];
bios = results[1];
}
else
{
model = obj["SMBIOSBIOSVersion"].ToString();
}
}
return "";
}
}
}
public void VisualiseDriver(DriverDownload driver, TableLayoutPanel table)
{