Skip to content

Portable Tool for an Ideal Windows Setup

fix error for missing parameters #45

Greedeks42cd0a8102ea
diff --git a/.Source/GTweak/App.xaml.cs b/.Source/GTweak/App.xaml.cs
index c5fd258e..c94c23b7 100644
--- a/.Source/GTweak/App.xaml.cs
+++ b/.Source/GTweak/App.xaml.cs
@@ -6,7 +6,6 @@ using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
-using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
diff --git a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
index 6ef49544..74c89a66 100644
--- a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
+++ b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
@@ -191,72 +191,68 @@ namespace GTweak.Utilities.Configuration
{
static (bool, string, string) GetMemorySize(string name)
{
- try
+ using RegistryKey baseKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}");
+ if (baseKey != null)
{
- using RegistryKey baseKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}");
- if (baseKey != null)
+ foreach (string subKeyName in baseKey.GetSubKeyNames())
{
- foreach (string subKeyName in baseKey.GetSubKeyNames())
+ if (subKeyName == "Properties")
+ continue;
+
+ using RegistryKey regKey = baseKey.OpenSubKey(subKeyName);
+ if (regKey != null)
{
- if (subKeyName == "Properties")
- continue;
+ string adapterString = regKey.GetValue("HardwareInformation.AdapterString") as string;
+ string driverDesc = regKey.GetValue("DriverDesc") as string;
+ object chipTypeValue = regKey.GetValue("HardwareInformation.ChipType");
+ string chipType = chipTypeValue as string ?? (chipTypeValue is byte[] chipTypeBytes ? Encoding.UTF8.GetString(chipTypeBytes) : string.Empty);
- using RegistryKey regKey = baseKey.OpenSubKey(subKeyName);
- if (regKey != null)
- {
- string adapterString = regKey.GetValue("HardwareInformation.AdapterString") as string;
- string driverDesc = regKey.GetValue("DriverDesc") as string;
- object chipTypeValue = regKey.GetValue("HardwareInformation.ChipType");
- string chipType = chipTypeValue as string ?? (chipTypeValue is byte[] chipTypeBytes ? Encoding.UTF8.GetString(chipTypeBytes) : string.Empty);
+ if ((!string.IsNullOrEmpty(adapterString) && adapterString.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0) ||
+ (!string.IsNullOrEmpty(driverDesc) && driverDesc.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0) ||
+ (!string.IsNullOrEmpty(chipType) && chipType.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0))
+ {
+ object memorySizeValue = regKey.GetValue("HardwareInformation.qwMemorySize") ?? regKey.GetValue("HardwareInformation.MemorySize");
- if ((!string.IsNullOrEmpty(adapterString) && adapterString.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0) ||
- (!string.IsNullOrEmpty(driverDesc) && driverDesc.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0) ||
- (!string.IsNullOrEmpty(chipType) && chipType.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0))
+ if (memorySizeValue != null)
{
- object memorySizeValue = regKey.GetValue("HardwareInformation.qwMemorySize") ?? regKey.GetValue("HardwareInformation.MemorySize");
- if (memorySizeValue != null)
- {
- ulong memorySize = 0;
+ ulong memorySize = 0;
- if (memorySizeValue is byte[] byteArray)
- {
- byte[] filledArray = new byte[8];
- Array.Copy(byteArray, filledArray, Math.Min(byteArray.Length, filledArray.Length));
- memorySize = BitConverter.ToUInt64(filledArray, 0);
- }
- else
+ if (memorySizeValue is byte[] byteArray)
+ {
+ byte[] filledArray = new byte[8];
+ Array.Copy(byteArray, filledArray, Math.Min(byteArray.Length, filledArray.Length));
+ memorySize = BitConverter.ToUInt64(filledArray, 0);
+ }
+ else
+ {
+ memorySize = memorySizeValue switch
{
- memorySize = memorySizeValue switch
- {
- int intValue => unchecked((uint)intValue),
- uint uintValue => uintValue,
- long longValue => unchecked((ulong)longValue),
- ulong ulongValue => ulongValue,
- _ => 0
- };
- }
-
- return (true, SizeCalculationHelper(memorySize), !string.IsNullOrEmpty(driverDesc) ? driverDesc : chipType);
+ int intValue => unchecked((uint)intValue),
+ uint uintValue => uintValue,
+ long longValue => unchecked((ulong)longValue),
+ ulong ulongValue => ulongValue,
+ _ => 0
+ };
}
+
+ return (true, SizeCalculationHelper(memorySize), !string.IsNullOrEmpty(driverDesc) ? driverDesc : chipType);
}
+ else
+ return (false, string.Empty, string.Empty);
}
}
}
- return (false, string.Empty, string.Empty);
- }
- catch (Exception ex)
- {
- ErrorLogging.LogDebug(ex);
- return (false, string.Empty, string.Empty);
}
+ return (false, string.Empty, string.Empty);
}
+
foreach (var managementObj in new ManagementObjectSearcher(@"root\cimv2", "select Name, AdapterRAM from Win32_VideoController", new EnumerationOptions { ReturnImmediately = true }).Get())
{
string data = managementObj["Name"] as string;
- (bool isFound, string dataMemoryReg, string driverDesc) = GetMemorySize(data);
- HardwareData.Graphics += $"{(data == null && !string.IsNullOrEmpty(driverDesc) ? driverDesc : data)}, {(isFound ? dataMemoryReg : SizeCalculationHelper((uint)managementObj["AdapterRAM"]))}\n";
+ (bool isFound, string dataMemoryReg, string driverDesc) = GetMemorySize(data);
+ HardwareData.Graphics += $"{(data == null && !string.IsNullOrEmpty(driverDesc) ? driverDesc : data)}, {(isFound && !string.IsNullOrEmpty(dataMemoryReg) ? dataMemoryReg : managementObj["AdapterRAM"] is uint valueRAM && managementObj["AdapterRAM"] != null ? SizeCalculationHelper(valueRAM) : "N/A")}\n";
}
HardwareData.Graphics = HardwareData.Graphics.TrimEnd('\n');
}