69 lines
1.7 KiB
C#
69 lines
1.7 KiB
C#
using FlybyScript;
|
|
using Microsoft.Win32;
|
|
using System;
|
|
using System.Drawing;
|
|
|
|
namespace Settings.Privacy
|
|
{
|
|
internal class LocationTracking : FeatureBase
|
|
{
|
|
public LocationTracking(Logger logger) : base(logger)
|
|
{
|
|
}
|
|
|
|
private const string keyName = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\LocationAndSensors";
|
|
private const string valueName = "LocationEnabled";
|
|
private const int desiredValue = 0;
|
|
|
|
public override string GetRegistryKey()
|
|
{
|
|
return $"{keyName} | Value: {valueName} | Desired Value: {desiredValue}";
|
|
}
|
|
|
|
public override string ID()
|
|
{
|
|
return "Disable location tracking";
|
|
}
|
|
|
|
public override string Info()
|
|
{
|
|
return "Disable location tracking (prevents Windows from accessing your location)";
|
|
}
|
|
|
|
public override bool CheckFeature()
|
|
{
|
|
return Utils.IntEquals(keyName, valueName,desiredValue);
|
|
}
|
|
|
|
public override bool DoFeature()
|
|
{
|
|
try
|
|
{
|
|
Registry.SetValue(keyName, valueName, 0, RegistryValueKind.DWord);
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.Log("Code red in " + ex.Message, Color.Red);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public override bool UndoFeature()
|
|
{
|
|
try
|
|
{
|
|
Registry.SetValue(keyName, valueName, 1, RegistryValueKind.DWord);
|
|
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.Log("Code red in " + ex.Message, Color.Red);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
} |