添加杀软保护提示

This commit is contained in:
蓝点lilac
2020-12-26 12:36:02 +08:00
parent 880265afe4
commit b648204bc7
3 changed files with 54 additions and 23 deletions

View File

@@ -34,13 +34,13 @@ namespace BulePointLilac.Methods
public static void MoveTo(this RegistryKey srcKey, RegistryKey dstKey)
{
CopyTo(srcKey, dstKey);
DeleteKeyTree(srcKey.Name);
DeleteKeyTree(srcKey.Name, true);
}
public static void MoveTo(string srcPath, string dstPath)
{
CopyTo(srcPath, dstPath);
DeleteKeyTree(srcPath);
DeleteKeyTree(srcPath, true);
}
public static RegistryKey CreateSubKey(this RegistryKey key, string subKeyName, bool writable)

View File

@@ -77,7 +77,15 @@ namespace ContextMenuManager.Controls
set
{
if(!value && TryProtectOpenItem) return;
RegistryEx.MoveTo(RegPath, BackupPath);
try
{
RegistryEx.MoveTo(RegPath, BackupPath);
}
catch
{
MessageBoxEx.Show(AppString.MessageBox.AuthorityProtection);
return;
}
RegPath = BackupPath;
}
}
@@ -234,8 +242,16 @@ namespace ContextMenuManager.Controls
public void DeleteMe()
{
RegistryEx.DeleteKeyTree(this.RegPath);
RegistryEx.DeleteKeyTree(this.BackupPath);
try
{
RegistryEx.DeleteKeyTree(this.RegPath, true);
RegistryEx.DeleteKeyTree(this.BackupPath, true);
}
catch
{
MessageBoxEx.Show(AppString.MessageBox.AuthorityProtection);
return;
}
this.Dispose();
}
}

View File

@@ -222,30 +222,37 @@ namespace ContextMenuManager.Controls
}
set
{
if(value)
try
{
RegistryEx.DeleteValue(RegPath, "CommandFlags");
RegistryEx.DeleteValue(RegPath, "HideBasedOnVelocityId");
RegistryEx.DeleteValue(RegPath, "LegacyDisable");
RegistryEx.DeleteValue(RegPath, "ProgrammaticAccessOnly");
}
else
{
if(TryProtectOpenItem) return;
if(!IsSubItem)
if(value)
{
Registry.SetValue(RegPath, "LegacyDisable", string.Empty);
Registry.SetValue(RegPath, "ProgrammaticAccessOnly", string.Empty);
}
else if(WindowsOsVersion.IsAfterOrEqualWin10_1703)
{
Registry.SetValue(RegPath, "HideBasedOnVelocityId", 0x639bc8);
RegistryEx.DeleteValue(RegPath, "CommandFlags");
RegistryEx.DeleteValue(RegPath, "HideBasedOnVelocityId");
RegistryEx.DeleteValue(RegPath, "LegacyDisable");
RegistryEx.DeleteValue(RegPath, "ProgrammaticAccessOnly");
}
else
{
MessageBoxEx.Show(AppString.MessageBox.CannotHideSubItem);
if(TryProtectOpenItem) return;
if(!IsSubItem)
{
Registry.SetValue(RegPath, "LegacyDisable", string.Empty);
Registry.SetValue(RegPath, "ProgrammaticAccessOnly", string.Empty);
}
else if(WindowsOsVersion.IsAfterOrEqualWin10_1703)
{
Registry.SetValue(RegPath, "HideBasedOnVelocityId", 0x639bc8);
}
else
{
MessageBoxEx.Show(AppString.MessageBox.CannotHideSubItem);
}
}
}
catch
{
MessageBoxEx.Show(AppString.MessageBox.AuthorityProtection);
}
}
}
@@ -505,7 +512,15 @@ namespace ContextMenuManager.Controls
public virtual void DeleteMe()
{
RegistryEx.DeleteKeyTree(this.RegPath);
try
{
RegistryEx.DeleteKeyTree(this.RegPath, true);
}
catch
{
MessageBoxEx.Show(AppString.MessageBox.AuthorityProtection);
return;
}
this.Dispose();
}
}