65 lines
1.9 KiB
C#
65 lines
1.9 KiB
C#
using Microsoft.Win32;
|
|
using System;
|
|
using CrapFixer;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Settings.System
|
|
{
|
|
internal class SystemResponsiveness : FeatureBase
|
|
{
|
|
private const string keyName = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile";
|
|
private const string valueName = "SystemResponsiveness";
|
|
private const int recommendedValue = 10;
|
|
|
|
public override string GetFeatureDetails()
|
|
{
|
|
return $"{keyName} | Value: {valueName} | Recommended Value: {recommendedValue}";
|
|
}
|
|
|
|
public override string ID()
|
|
{
|
|
return "Optimize System Responsiveness";
|
|
}
|
|
|
|
public override string Info()
|
|
{
|
|
return "Enhances system responsiveness by prioritizing CPU resources for foreground tasks, improving performance during active use.";
|
|
}
|
|
|
|
public override Task<bool> CheckFeature()
|
|
{
|
|
return Task.FromResult(Utils.IntEquals(keyName, valueName, recommendedValue));
|
|
}
|
|
|
|
public override Task<bool> DoFeature()
|
|
{
|
|
try
|
|
{
|
|
Registry.SetValue(keyName, valueName, recommendedValue, RegistryValueKind.DWord);
|
|
return Task.FromResult(true);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.Log("Code red in " + ex.Message, LogLevel.Error);
|
|
}
|
|
|
|
return Task.FromResult(false);
|
|
}
|
|
|
|
public override bool UndoFeature()
|
|
{
|
|
try
|
|
{
|
|
Registry.SetValue(keyName, valueName, 20, RegistryValueKind.DWord); // Default is typically 20 on Windows 11
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.Log("Code red in " + ex.Message, LogLevel.Error);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|