66 lines
1.8 KiB
C#
66 lines
1.8 KiB
C#
using Microsoft.Win32;
|
|
using System;
|
|
using Crapfixer;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Settings.Personalization
|
|
{
|
|
internal class LockScreen : FeatureBase
|
|
{
|
|
private const string keyName = @"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Personalization";
|
|
private const string valueName = "NoLockScreen";
|
|
private const int recommendedValue = 0;
|
|
|
|
public override string GetFeatureDetails()
|
|
{
|
|
return $"{keyName} | Value: {valueName} | Recommended Value: {recommendedValue}";
|
|
}
|
|
|
|
public override string ID()
|
|
{
|
|
return "Don't use personalized lock screen";
|
|
}
|
|
|
|
public override string Info()
|
|
{
|
|
return "This feature will disable the personalized lock screen.";
|
|
}
|
|
|
|
public override Task<bool> CheckFeature()
|
|
{
|
|
bool result = !Utils.IntEquals(keyName, valueName, recommendedValue);
|
|
return Task.FromResult(result);
|
|
}
|
|
|
|
|
|
public override Task<bool> DoFeature()
|
|
{
|
|
try
|
|
{
|
|
Registry.SetValue(keyName, valueName, 1, 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, 0, RegistryValueKind.DWord);
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.Log("Code red in " + ex.Message, LogLevel.Error);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
} |