/
DisableCortana.cs
59 lines (50 loc) 路 1.81 KB
/
DisableCortana.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
锘縰sing Microsoft.Win32;
using Privatezilla.Locales;
namespace Privatezilla.Setting.Cortana
{
internal class DisableCortana : SettingBase
{
private const string CortanaKey = @"HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Windows Search";
private const string CortanaIconKey = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced";
private const int DesiredValue = 0;
public override string ID()
{
return Locale.settingsCortanaDisableCortana;
}
public override string Info()
{
return Locale.settingsCortanaDisableCortanaInfo.Replace("\\n", "\n");
}
public override bool CheckSetting()
{
return !(
RegistryHelper.IntEquals(CortanaKey, "AllowCortana", DesiredValue) &&
RegistryHelper.IntEquals(CortanaIconKey, "ShowCortanaButton", DesiredValue)
);
}
public override bool DoSetting()
{
try
{
Registry.SetValue(CortanaKey, "AllowCortana", DesiredValue, RegistryValueKind.DWord);
Registry.SetValue(CortanaIconKey, "ShowCortanaButton", DesiredValue, RegistryValueKind.DWord);
return true;
}
catch
{ }
return false;
}
public override bool UndoSetting()
{
try
{
Registry.SetValue(CortanaKey, "AllowCortana", 1, RegistryValueKind.DWord);
Registry.SetValue(CortanaIconKey, "ShowCortanaButton", 1, RegistryValueKind.DWord);
return true;
}
catch
{ }
return false;
}
}
}