Here are the examples of the csharp api Microsoft.Win32.RegistryKey.DeleteValue(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
188 Examples
19
Source : Program.cs
with MIT License
from 0x727
with MIT License
from 0x727
public static void RegeditKeyExist(string regpath)
{
string[] subkeyNames;
RegistryKey sd = Registry.LocalMachine.OpenSubKey(regpath, true);
subkeyNames = sd.GetValueNames();
foreach (string keyName in subkeyNames)
{
if (keyName == "SD")
{
sd.DeleteValue("SD");
sd.Close();
return;
}
}
sd.Close();
return;
}
19
Source : Program.cs
with BSD 3-Clause "New" or "Revised" License
from 0xthirteen
with BSD 3-Clause "New" or "Revised" License
from 0xthirteen
static void Clereplacedl()
{
try
{
string keypath = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU";
Console.WriteLine("HKCU:{0}", keypath);
RegistryKey regkey;
regkey = Registry.CurrentUser.OpenSubKey(keypath, true);
if (regkey.ValueCount > 0)
{
foreach (string subKey in regkey.GetValueNames())
{
regkey.DeleteValue(subKey);
}
}
Console.WriteLine("[+] Cleaned all RunMRU values");
regkey.Close();
}
catch (Exception ex)
{
Console.WriteLine("[-] Error: {0}", ex.Message);
}
}
19
Source : Program.cs
with BSD 3-Clause "New" or "Revised" License
from 0xthirteen
with BSD 3-Clause "New" or "Revised" License
from 0xthirteen
static void CleanSingle(string command)
{
string keypath = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU";
string keyvalue = string.Empty;
string regcmd = string.Empty;
if (command.EndsWith("\\1"))
{
regcmd = command;
}
else
{
regcmd = string.Format("{0}\\1", command);
}
try
{
RegistryKey regkey;
regkey = Registry.CurrentUser.OpenSubKey(keypath, true);
if (regkey.ValueCount > 0)
{
foreach (string subKey in regkey.GetValueNames())
{
if(regkey.GetValue(subKey).ToString() == regcmd)
{
keyvalue = subKey;
regkey.DeleteValue(subKey);
Console.WriteLine(regcmd);
Console.WriteLine("[+] Cleaned {0} from HKCU:{1}", command, keypath);
}
}
if(keyvalue != string.Empty)
{
string mruchars = regkey.GetValue("MRUList").ToString();
int index = mruchars.IndexOf(keyvalue);
mruchars = mruchars.Remove(index, 1);
regkey.SetValue("MRUList", mruchars);
}
}
regkey.Close();
}
catch (ArgumentException)
{
Console.WriteLine("[-] Error: Selected Registry value does not exist");
}
}
19
Source : AutoStarter.cs
with MIT License
from AlexanderPro
with MIT License
from AlexanderPro
public static void UnsetAutoStartByRegister(string keyName)
{
using (var key = Registry.CurrentUser.CreateSubKey(RUN_LOCATION))
{
key.DeleteValue(keyName);
}
}
19
Source : StartUpManager.cs
with MIT License
from AlexanderPro
with MIT License
from AlexanderPro
public static void RemoveFromStartup(string keyName)
{
using (var key = Registry.CurrentUser.OpenSubKey(RUN_LOCATION, true))
{
key.DeleteValue(keyName);
}
}
19
Source : StartupManager.cs
with MIT License
from AlexGyver
with MIT License
from AlexGyver
private void DeleteRegistryRun() {
RegistryKey key = Registry.CurrentUser.CreateSubKey(REGISTRY_RUN);
key.DeleteValue("OpenHardwareMonitor");
}
19
Source : RegistryConfig.cs
with GNU General Public License v3.0
from aloopkin
with GNU General Public License v3.0
from aloopkin
public void DeleteParameter(string parameter)
{
RegistryKey key = Registry.LocalMachine.OpenSubKey(_subKey, true);
if (key != null)
{
key.DeleteValue(parameter);
}
}
19
Source : RegistryLifoList.cs
with Apache License 2.0
from AmpScm
with Apache License 2.0
from AmpScm
public void Clear()
{
using (RegistryKey key = OpenFifoKey(false))
{
key.SetValue("_pos", 0);
string[] names = key.GetValueNames();
Array.Sort<string>(names);
foreach (string name in names)
{
if (name.StartsWith("#"))
key.DeleteValue(name);
}
}
}
19
Source : RegistryLifoList.cs
with Apache License 2.0
from AmpScm
with Apache License 2.0
from AmpScm
public bool Remove(string item)
{
foreach (KeyValuePair<string, string> kv in (IEnumerable<KeyValuePair<string, string>>)this)
{
if (kv.Value == item)
{
using (RegistryKey key = OpenFifoKey(false))
{
key.DeleteValue(kv.Key);
return true;
}
}
}
return false;
}
19
Source : SettingsKey.cs
with Apache License 2.0
from AmpScm
with Apache License 2.0
from AmpScm
public void DeleteValue(string strName)
{
m_Key.DeleteValue(strName);
}
19
Source : FileAssociation.cs
with GNU General Public License v3.0
from audiamus
with GNU General Public License v3.0
from audiamus
private static bool deleteValue (string keyPath, string name = null) {
bool dirty = false;
using (var key = Registry.CurrentUser.OpenSubKey (keyPath, true)) {
if (key is null)
return false;
name = name ?? string.Empty;
var names = key.GetValueNames ();
if (names.Contains (name) || name == String.Empty)
dirty = true;
key.DeleteValue (name);
}
return dirty;
}
19
Source : AyFuncRegisterTable.cs
with MIT License
from ay2015
with MIT License
from ay2015
public void Delete(string name)
{
using (RegistryKey delKey = Registry.LocalMachine.OpenSubKey("Software\\" + AyFuncConfig.TableSoftwareName, true))
{
delKey.DeleteValue(name);
}
}
19
Source : CustomAction.cs
with Apache License 2.0
from BuffettCode
with Apache License 2.0
from BuffettCode
[CustomAction]
public static ActionResult CaUnRegisterAddIn(Session session)
{
string szOfficeRegKeyVersions = string.Empty;
string szBaseAdreplacedey = @"Software\Microsoft\Office\";
string szXll32Bit = string.Empty;
string szXll64Bit = string.Empty;
string szFolder = string.Empty;
bool bFoundOffice = false;
List<string> lstVersions;
try
{
session.Log("Begin CaUnRegisterAddIn");
szOfficeRegKeyVersions = session["OFFICEREGKEYS"];
szXll32Bit = session["XLL32"];
szXll64Bit = session["XLL64"];
szFolder = session["AddinFolder"];
szXll32Bit = szFolder.ToString() + szXll32Bit.ToString();
szXll64Bit = szFolder.ToString() + szXll64Bit.ToString();
if (szOfficeRegKeyVersions.Length > 0)
{
lstVersions = szOfficeRegKeyVersions.Split(',').ToList();
foreach (string szOfficeVersionKey in lstVersions)
{
// only remove keys where office version is found
if (Registry.CurrentUser.OpenSubKey(szBaseAdreplacedey + szOfficeVersionKey, false) != null)
{
bFoundOffice = true;
string szKeyName = szBaseAdreplacedey + szOfficeVersionKey + @"\Excel\Options";
RegistryKey rkAdreplacedey = Registry.CurrentUser.OpenSubKey(szKeyName, true);
if (rkAdreplacedey != null)
{
string[] szValueNames = rkAdreplacedey.GetValueNames();
foreach (string szValueName in szValueNames)
{
//unregister both 32 and 64 xll
if (szValueName.StartsWith("OPEN") && (rkAdreplacedey.GetValue(szValueName).ToString().Contains(szXll32Bit) || rkAdreplacedey.GetValue(szValueName).ToString().Contains(szXll64Bit)))
{
rkAdreplacedey.DeleteValue(szValueName);
}
}
}
}
}
}
session.Log("End CaUnRegisterAddIn");
}
catch (Exception ex)
{
session.Log(ex.Message);
}
return bFoundOffice ? ActionResult.Success : ActionResult.Failure;
}
19
Source : DisableFeedback.cs
with MIT License
from builtbybel
with MIT License
from builtbybel
public override bool UndoSetting()
{
try
{
var RegKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Siuf\Rules", true);
RegKey.DeleteValue("NumberOfSIUFInPeriod");
RegKey.DeleteValue("PeriodInNanoSeconds");
return true;
}
catch
{ }
return false;
}
19
Source : DisableTimeline.cs
with MIT License
from builtbybel
with MIT License
from builtbybel
public override bool UndoSetting()
{
try
{
var RegKey = Registry.LocalMachine.OpenSubKey(@"Software\Policies\Microsoft\Windows\System", true);
RegKey.DeleteValue("EnableActivityFeed");
RegKey.DeleteValue("PublishUserActivities");
return true;
}
catch
{ }
return false;
}
19
Source : DisableSmartScreenStore.cs
with MIT License
from builtbybel
with MIT License
from builtbybel
public override bool UndoSetting()
{
try
{
var RegKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\AppHost", true);
RegKey.DeleteValue("EnableWebContentEvaluation");
return true;
}
catch
{ }
return false;
}
19
Source : DisableCompTelemetry.cs
with MIT License
from builtbybel
with MIT License
from builtbybel
public override bool UndoSetting()
{
try
{
var RegKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\CompatTelRunner.exe", true);
RegKey.DeleteValue("Debugger");
return true;
}
catch
{ }
return false;
}
19
Source : BlockMajorUpdates.cs
with MIT License
from builtbybel
with MIT License
from builtbybel
public override bool UndoSetting()
{
try
{
var RegKey = Registry.LocalMachine.OpenSubKey(@"Software\Policies\Microsoft\Windows\WindowsUpdate", true);
RegKey.DeleteValue("TargetReleaseVersion");
RegKey.DeleteValue("TargetReleaseVersionInfo");
return true;
}
catch
{ }
return false;
}
19
Source : DisableSafeguards.cs
with MIT License
from builtbybel
with MIT License
from builtbybel
public override bool UndoSetting()
{
try
{
var RegKey = Registry.LocalMachine.OpenSubKey(@"Software\Policies\Microsoft\Windows\WindowsUpdate", true);
RegKey.DeleteValue("DisableWUfBSafeguards");
return true;
}
catch
{ }
return false;
}
19
Source : DisableUpdates.cs
with MIT License
from builtbybel
with MIT License
from builtbybel
public override bool UndoSetting()
{
try
{
Registry.SetValue(NoAutoUpdate, "NoAutoUpdate", 0, RegistryValueKind.DWord);
var RegKey = Registry.LocalMachine.OpenSubKey(@"Software\Policies\Microsoft\Windows\WindowsUpdate\AU", true);
RegKey.DeleteValue("AUOptions");
RegKey.DeleteValue("ScheduledInstallDay");
RegKey.DeleteValue("ScheduledInstallTime");
return true;
}
catch
{ }
return false;
}
19
Source : UpdatesSharing.cs
with MIT License
from builtbybel
with MIT License
from builtbybel
public override bool UndoSetting()
{
try
{
var RegKey = Registry.LocalMachine.OpenSubKey(@"Software\Policies\Microsoft\Windows\DeliveryOptimization", true);
RegKey.DeleteValue("DODownloadMode");
return true;
}
catch
{ }
return false;
}
19
Source : CompatibilityTelemetry.cs
with MIT License
from builtbybel
with MIT License
from builtbybel
public override bool Undoreplacedessment()
{
try
{
var RegKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\CompatTelRunner.exe", true);
RegKey.DeleteValue("Debugger");
logger.Log("- Compatibility Telemetry has been successfully enabled.");
return true;
}
catch
{ }
return false;
}
19
Source : Feedback.cs
with MIT License
from builtbybel
with MIT License
from builtbybel
public override bool Undoreplacedessment()
{
try
{
var RegKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Siuf\Rules", true);
RegKey.DeleteValue("NumberOfSIUFInPeriod");
RegKey.DeleteValue("PeriodInNanoSeconds");
logger.Log("- Feedback has been successfully enabled.");
return true;
}
catch
{ }
return false;
}
19
Source : PowerThrottling.cs
with MIT License
from builtbybel
with MIT License
from builtbybel
public override bool Undoreplacedessment()
{
try
{
var RegKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Power\PowerThrottling", true);
RegKey.DeleteValue("PowerThrottlingOff");
logger.Log("- PowerThrottling has been successfully enabled.");
logger.Log(keyName);
return true;
}
catch
{ }
return false;
}
19
Source : TeamsAutostart.cs
with MIT License
from builtbybel
with MIT License
from builtbybel
public override bool Doreplacedessment()
{
try
{
var RegKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
RegKey.DeleteValue("com.squirrel.Teams.Teams");
logger.Log("- Teams AutoStart has been disabled.");
return true;
}
catch
{ }
return false;
}
19
Source : FileExplorer.cs
with MIT License
from builtbybel
with MIT License
from builtbybel
public override bool Undoreplacedessment()
{
try
{
var RegKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked", true);
RegKey.DeleteValue("{e2bf9676-5f8f-435c-97eb-11607a5bedf7}");
logger.Log("- Windows 10 File Explorer has been successfully disabled.\nRestart is required for the changes to take effect!");
return true;
}
catch
{ }
return false;
}
19
Source : MostUsedApps.cs
with MIT License
from builtbybel
with MIT License
from builtbybel
public override bool Undoreplacedessment()
{
try
{
var RegKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Policies\Microsoft\Windows\Explorer", true);
RegKey.DeleteValue("ShowOrHideMostUsedApps");
logger.Log("- Most Used Apps has been set to default behavior.");
return true;
}
catch
{ }
return false;
}
19
Source : StartupRunner.cs
with Apache License 2.0
from cairoshell
with Apache License 2.0
from cairoshell
private List<StartupEntry> GetAppsFromRegistryKey(StartupLocation location)
{
RegistryKey[] roots = ScopeToRoots(location.Scope);
List<StartupEntry> startupApps = new List<StartupEntry>();
foreach (var root in roots)
{
bool isRunOnce = location.Location.Contains("RunOnce");
try
{
if (isRunOnce && root == Registry.LocalMachine)
continue; // skip HKLM RunOnce since we cannot delete these items, and would run them each startup
RegistryKey registryKey =
root.OpenSubKey(location.Location, root == Registry.CurrentUser); // open as writeable if HKCU
if (registryKey != null && registryKey.ValueCount > 0)
{
// get list of disallowed entries
List<string> disallowedItems = GetDisallowedItems(location, root == Registry.LocalMachine ? StartupEntryScope.Machine : StartupEntryScope.User);
// add items from registry key
foreach (var valueName in registryKey.GetValueNames())
{
// only add items that are not disabled
if (!disallowedItems.Contains(valueName))
{
startupApps.Add(new StartupEntry
{
Location = location,
Path = ((string)registryKey.GetValue(valueName)).Replace("\"", "")
});
// if this is a runonce key, remove the value after we grab it
if (isRunOnce)
{
try
{
registryKey.DeleteValue(valueName);
}
catch
{
ShellLogger.Warning($"StartupRunner: Unable to delete RunOnce startup item {valueName}");
}
}
}
}
}
// close key when finished
registryKey?.Close();
}
catch
{
ShellLogger.Warning($"StartupRunner: Unable to load startup items from registry key {location.Location}");
}
}
return startupApps;
}
19
Source : PatcherInstaller.cs
with GNU General Public License v3.0
from Ceiridge
with GNU General Public License v3.0
from Ceiridge
public bool Install(WriteToLog log, List<int> disabledGroups) {
using (TaskService ts = new TaskService()) {
foreach (Task task in ts.RootFolder.Tasks) {
if (task.Name.Equals("ChromeDllInjector")) {
if (task.State == TaskState.Running) {
task.Stop();
}
}
}
}
SendNotifyMessage(new IntPtr(0xFFFF), 0x0, UIntPtr.Zero, IntPtr.Zero); // HWND_BROADCAST a WM_NULL to make sure every injected dll unloads
Thread.Sleep(1000); // Give Windows some time to unload all patch dlls
using (RegistryKey dllPathKeys = OpenExesKey()) {
foreach (string valueName in dllPathKeys.GetValueNames()) {
if (valueName.Length > 0) {
dllPathKeys.DeleteValue(valueName);
}
}
log("Cleared ChromeExes registry");
int i = 0;
foreach (InstallationPaths paths in this.installationPaths) {
string appDir = Path.GetDirectoryName(paths.ChromeExePath!)!;
// Write patch data info file
byte[] patchData = GetPatchFileBinary(paths, disabledGroups);
File.WriteAllBytes(Path.Combine(appDir, "ChromePatches.bin"), patchData);
log("Wrote patch file to " + appDir);
// Add chrome dll to the registry key
dllPathKeys.SetValue(i.ToString(), paths.ChromeExePath!);
i++;
log("Appended " + paths.ChromeDllPath + " to the registry key");
}
}
// Write the injector to "Program Files"
DirectoryInfo programsFolder = GetProgramsFolder();
string patcherDllPath = Path.Combine(programsFolder.FullName, "ChromePatcherDll_" + Installation.GetUnixTime() + ".dll"); // Unique dll to prevent file locks
if (!programsFolder.Exists) {
Directory.CreateDirectory(programsFolder.FullName); // Also creates all subdirectories
}
using (ZipArchive zip = new ZipArchive(new MemoryStream(Properties.Resources.ChromeDllInjector), ZipArchiveMode.Read)) {
foreach (ZipArchiveEntry entry in zip.Entries) {
string combinedPath = Path.Combine(programsFolder.FullName, entry.FullName);
new FileInfo(combinedPath).Directory?.Create(); // Create the necessary folders that contain the file
using Stream entryStream = entry.Open();
using FileStream writeStream = File.OpenWrite(combinedPath);
entryStream.CopyTo(writeStream);
}
}
log("Extracted injector zip");
TryDeletePatcherDlls(programsFolder);
File.WriteAllBytes(patcherDllPath, Properties.Resources.ChromePatcherDll);
log("Wrote patcher dll to " + patcherDllPath);
using (TaskService ts = new TaskService()) {
TaskDefinition task = ts.NewTask();
task.RegistrationInfo.Author = "Ceiridge";
task.RegistrationInfo.Description = "A logon task that automatically injects the ChromePatcher.dll into every Chromium process that the user installed the patcher on. This makes removing the Developer Mode Extension Warning possible.";
task.RegistrationInfo.URI = "https://github.com/Ceiridge/Chrome-Developer-Mode-Extension-Warning-Patcher";
task.Triggers.Add(new LogonTrigger { });
task.Actions.Add(new ExecAction(Path.Combine(programsFolder.FullName, "ChromeDllInjector.exe")));
task.Principal.RunLevel = TaskRunLevel.Highest;
task.Principal.LogonType = TaskLogonType.InteractiveToken;
task.Settings.StopIfGoingOnBatteries = task.Settings.DisallowStartIfOnBatteries = false;
task.Settings.RestartCount = 3;
task.Settings.RestartInterval = new TimeSpan(0, 1, 0);
task.Settings.Hidden = true;
task.Settings.ExecutionTimeLimit = task.Settings.DeleteExpiredTaskAfter = TimeSpan.Zero;
Task tsk = ts.RootFolder.RegisterTaskDefinition("ChromeDllInjector", task, TaskCreation.CreateOrUpdate, WindowsIdenreplacedy.GetCurrent().Name, null, TaskLogonType.InteractiveToken);
if (tsk.State != TaskState.Running) {
tsk.Run();
}
log("Created and started task");
}
log("Patches installed!");
return true;
}
19
Source : PatcherInstaller.cs
with GNU General Public License v3.0
from Ceiridge
with GNU General Public License v3.0
from Ceiridge
public bool UninstallAll(WriteToLog log) {
using (TaskService ts = new TaskService()) {
foreach (Task task in ts.RootFolder.Tasks) {
if (task.Name.Equals("ChromeDllInjector")) {
if (task.State == TaskState.Running) {
task.Stop();
}
ts.RootFolder.DeleteTask("ChromeDllInjector");
log("Deleted and stopped task");
}
}
}
SendNotifyMessage(new IntPtr(0xFFFF), 0x0, UIntPtr.Zero, IntPtr.Zero); // HWND_BROADCAST a WM_NULL to make sure every injected dll unloads
Thread.Sleep(1000); // Give Windows some time to unload all patch dlls
using (RegistryKey dllPathKeys = OpenExesKey()) {
foreach (string valueName in dllPathKeys.GetValueNames()) {
if (valueName.Length > 0) {
dllPathKeys.DeleteValue(valueName);
}
}
log("Cleared ChromeExes registry");
}
foreach (InstallationPaths paths in this.installationPaths) {
string appDir = Path.GetDirectoryName(paths.ChromeExePath!)!;
string patchesFile = Path.Combine(appDir, "ChromePatches.bin");
if (File.Exists(patchesFile)) {
File.Delete(patchesFile);
}
log("Deleted patch files for " + appDir);
}
DirectoryInfo programsFolder = GetProgramsFolder();
if (programsFolder.Exists) {
TryDeletePatcherDlls(programsFolder);
DeleteFolderRecursively(programsFolder);
log("(Mostly) deleted " + programsFolder.FullName);
}
log("Patcher uninstalled!");
return true;
}
19
Source : Reg_Operation.cs
with GNU Affero General Public License v3.0
from ceramicskate0
with GNU Affero General Public License v3.0
from ceramicskate0
internal static void DELETE_SWELF_Reg_Key(REG_KEY Key)
{
try
{
BASE_SWELF_KEY.DeleteValue(SWELF_Keys[(int)Key]);
}
catch(Exception e)
{
if (e.Message.Contains("No value exists with that name")==false)
{
Error_Operation.Log_Error("DELETE_SWELF_Reg_Key()", e.Message.ToString(), e.StackTrace.ToString(), Error_Operation.LogSeverity.Verbose);
}
}
}
19
Source : RegistryHelper.cs
with Apache License 2.0
from Chem4Word
with Apache License 2.0
from Chem4Word
public static void SendSetupActions()
{
string module = $"{_product}.{_clreplaced}.{MethodBase.GetCurrentMethod().Name}()";
RegistryKey rk = Registry.CurrentUser.OpenSubKey(Constants.Chem4WordSetupRegistryKey, true);
if (rk != null)
{
string[] names = rk.GetValueNames();
List<string> values = new List<string>();
foreach (var name in names)
{
string message = rk.GetValue(name).ToString();
string timestamp = name;
int bracket = timestamp.IndexOf("[", StringComparison.InvariantCulture);
if (bracket > 0)
{
timestamp = timestamp.Substring(0, bracket).Trim();
}
values.Add($"{timestamp} {message}");
rk.DeleteValue(name);
}
if (values.Any())
{
Globals.Chem4WordV3.Telemetry.Write(module, "Setup", string.Join(Environment.NewLine, values));
}
}
}
19
Source : RegistryHelper.cs
with Apache License 2.0
from Chem4Word
with Apache License 2.0
from Chem4Word
public static void SendUpdateActions()
{
string module = $"{_product}.{_clreplaced}.{MethodBase.GetCurrentMethod().Name}()";
RegistryKey rk = Registry.CurrentUser.OpenSubKey(Constants.Chem4WordUpdateRegistryKey, true);
if (rk != null)
{
string[] names = rk.GetValueNames();
List<string> values = new List<string>();
foreach (var name in names)
{
string message = rk.GetValue(name).ToString();
string timestamp = name;
int bracket = timestamp.IndexOf("[", StringComparison.InvariantCulture);
if (bracket > 0)
{
timestamp = timestamp.Substring(0, bracket).Trim();
}
values.Add($"{timestamp} {message}");
rk.DeleteValue(name);
}
if (values.Any())
{
Globals.Chem4WordV3.Telemetry.Write(module, "Update", string.Join(Environment.NewLine, values));
}
}
}
19
Source : RegistryHelper.cs
with Apache License 2.0
from Chem4Word
with Apache License 2.0
from Chem4Word
public static void SendExceptions()
{
string module = $"{_product}.{_clreplaced}.{MethodBase.GetCurrentMethod().Name}()";
RegistryKey rk = Registry.CurrentUser.OpenSubKey(Constants.Chem4WordExceptionsRegistryKey, true);
int messageSize = 0;
if (rk != null)
{
string[] names = rk.GetValueNames();
List<string> values = new List<string>();
foreach (var name in names)
{
string message = rk.GetValue(name).ToString();
string timestamp = name;
int bracket = timestamp.IndexOf("[", StringComparison.InvariantCulture);
if (bracket > 0)
{
timestamp = timestamp.Substring(0, bracket).Trim();
}
values.Add($"{timestamp} {message}");
messageSize += timestamp.Length + message.Length;
if (messageSize > 30000)
{
SendData(module, values);
values = new List<string>();
messageSize = 0;
}
rk.DeleteValue(name);
}
SendData(module, values);
}
}
19
Source : Setup.cs
with Apache License 2.0
from Chem4Word
with Apache License 2.0
from Chem4Word
private void HandleNextState()
{
switch (_state)
{
case State.DownloadVsto:
// Download VSTO
RegistryHelper.WriteAction("Downloading VSTO");
Information.Text = "Downloading VSTO ...";
VstoInstalled.Indicator = Properties.Resources.Downloading;
if (DownloadFile(ChangeDomain(VstoInstaller)))
{
_previousState = _state;
_state = State.WaitingForVstoDownload;
}
else
{
VstoInstalled.Indicator = Properties.Resources.No;
Information.Text = $"Error downloading VSTO; {Information.Text}";
Action.Text = "Exit";
_state = State.Done;
}
break;
case State.WaitingForVstoDownload:
break;
case State.InstallVsto:
// Install VSTO
RegistryHelper.WriteAction("Installing VSTO");
Information.Text = "Installing VSTO ...";
try
{
VstoInstalled.Indicator = Properties.Resources.Runing;
_state = State.WaitingForInstaller;
int exitCode = RunProcess(_downloadedFile, "/preplacedive /norestart");
RegistryHelper.WriteAction($"VSTO ExitCode: {exitCode}");
switch (exitCode)
{
case 0: // Success.
case 1641: // Success - Reboot started.
case 3010: // Success - Reboot required.
VstoInstalled.Indicator = Properties.Resources.Yes;
_retryCount = 0;
_state = State.DownloadChem4Word;
break;
default:
VstoInstalled.Indicator = Properties.Resources.No;
Information.Text = $"Error installing VSTO; ExitCode: {exitCode}";
Action.Text = "Exit";
_state = State.Done;
break;
}
}
catch (Exception ex)
{
Information.Text = ex.Message;
Debug.WriteLine(ex.Message);
Action.Text = "Exit";
Action.Enabled = true;
timer1.Enabled = false;
_state = State.Done;
}
break;
case State.DownloadChem4Word:
// Download Chem4Word
RegistryHelper.WriteAction($"Downloading {_latestVersion}");
Information.Text = "Downloading Chem4Word ...";
AddInInstalled.Indicator = Properties.Resources.Downloading;
if (DownloadFile(_latestVersion))
{
_previousState = _state;
_state = State.WaitingForChem4WordDownload;
}
else
{
AddInInstalled.Indicator = Properties.Resources.No;
Information.Text = $"Error downloading Chem4Word; {Information.Text}";
Action.Text = "Exit";
_state = State.Done;
}
break;
case State.WaitingForChem4WordDownload:
break;
case State.InstallChem4Word:
// Install Chem4Word
RegistryHelper.WriteAction("Installing Chem4Word");
Information.Text = "Installing Chem4Word ...";
try
{
AddInInstalled.Indicator = Properties.Resources.Runing;
_state = State.WaitingForInstaller;
int exitCode = RunProcess(_downloadedFile, "");
RegistryHelper.WriteAction($"Chem4Word ExitCode: {exitCode}");
if (exitCode == 0)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(RegistryKeyName, true);
if (key == null)
{
key = Registry.CurrentUser.CreateSubKey(RegistryKeyName);
}
if (key != null)
{
try
{
// Erase previously stored Update Checks etc
foreach (string keyName in key.GetSubKeyNames())
{
key.DeleteValue(keyName);
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
progressBar1.Value = 0;
progressBar1.Maximum = 100;
progressBar1.Value = 100;
AddInInstalled.Indicator = Properties.Resources.Yes;
Information.Text = "Chem4Word successfully installed. Please start Microsoft Word, then select Chemistry Tab in ribbon";
Action.Text = "Finish";
}
else
{
AddInInstalled.Indicator = Properties.Resources.No;
Information.Text = $"Error installing Chem4Word; ExitCode: {exitCode}";
Action.Text = "Exit";
_state = State.Done;
}
}
catch (Exception ex)
{
Information.Text = ex.Message;
Debug.WriteLine(ex.Message);
Action.Text = "Exit";
}
Action.Enabled = true;
timer1.Enabled = false;
_state = State.Done;
break;
case State.WaitingForInstaller:
break;
case State.Done:
timer1.Enabled = false;
Action.Enabled = true;
break;
}
}
19
Source : CustomAction.cs
with Apache License 2.0
from Chem4Word
with Apache License 2.0
from Chem4Word
private static void EraseUserKey(Session session, string nameOfKey)
{
session.Log($" {nameof(EraseUserKey)}({nameOfKey})");
RegistryKey key = Registry.CurrentUser.OpenSubKey(nameOfKey, true);
if (key == null)
{
key = Registry.CurrentUser.CreateSubKey(nameOfKey);
}
if (key != null)
{
try
{
var values = key.GetValueNames();
// Erase previously stored Update Checks etc
foreach (string value in values)
{
session.Log($"Deleting Value '{value}'");
key.DeleteValue(value);
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
}
19
Source : CustomAction.cs
with Apache License 2.0
from Chem4Word
with Apache License 2.0
from Chem4Word
private static void DeleteUserKey(Session session, string nameOfKey, string kkk)
{
session.Log($" {nameof(DeleteUserKey)}({nameOfKey}, {kkk})");
RegistryKey key = Registry.CurrentUser.OpenSubKey($"{nameOfKey}{kkk}", true);
if (key != null)
{
try
{
var values = key.GetValueNames();
foreach (string value in values)
{
session.Log($"Deleting Value '{value}'");
key.DeleteValue(value);
}
key = Registry.CurrentUser.OpenSubKey($"{nameOfKey}", true);
key?.DeleteSubKey(kkk);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
}
19
Source : Setup.cs
with Apache License 2.0
from Chem4Word
with Apache License 2.0
from Chem4Word
private void HandleNextState()
{
switch (_state)
{
case State.DownloadVsto:
// Download VSTO
RegistryHelper.WriteAction("Downloading VSTO");
Information.Text = "Downloading VSTO ...";
VstoInstalled.Indicator = Properties.Resources.Downloading;
if (DownloadFile(ChangeDomain(VstoInstaller)))
{
_previousState = _state;
_state = State.WaitingForVstoDownload;
}
else
{
VstoInstalled.Indicator = Properties.Resources.No;
Information.Text = $"Error downloading VSTO; {Information.Text}";
Action.Text = "Exit";
_state = State.Done;
}
break;
case State.WaitingForVstoDownload:
break;
case State.InstallVsto:
// Install VSTO
RegistryHelper.WriteAction("Installing VSTO");
Information.Text = "Installing VSTO ...";
try
{
VstoInstalled.Indicator = Properties.Resources.Runing;
_state = State.WaitingForInstaller;
int exitCode = RunProcess(_downloadedFile, "/preplacedive /norestart");
RegistryHelper.WriteAction($"VSTO ExitCode: {exitCode}");
switch (exitCode)
{
case 0: // Success.
case 1641: // Success - Reboot started.
case 3010: // Success - Reboot required.
VstoInstalled.Indicator = Properties.Resources.Yes;
_retryCount = 0;
_state = State.DownloadChem4Word;
break;
default:
VstoInstalled.Indicator = Properties.Resources.No;
Information.Text = $"Error installing VSTO; ExitCode: {exitCode}";
Action.Text = "Exit";
_state = State.Done;
break;
}
}
catch (Exception ex)
{
Information.Text = ex.Message;
Debug.WriteLine(ex.Message);
Action.Text = "Exit";
Action.Enabled = true;
timer1.Enabled = false;
_state = State.Done;
}
break;
case State.DownloadChem4Word:
// Download Chem4Word
RegistryHelper.WriteAction($"Downloading {_latestVersion}");
Information.Text = "Downloading Chem4Word ...";
AddInInstalled.Indicator = Properties.Resources.Downloading;
if (DownloadFile(_latestVersion))
{
_previousState = _state;
_state = State.WaitingForChem4WordDownload;
}
else
{
AddInInstalled.Indicator = Properties.Resources.No;
Information.Text = $"Error downloading Chem4Word; {Information.Text}";
Action.Text = "Exit";
_state = State.Done;
}
break;
case State.WaitingForChem4WordDownload:
break;
case State.InstallChem4Word:
// Install Chem4Word
RegistryHelper.WriteAction("Installing Chem4Word");
Information.Text = "Installing Chem4Word ...";
try
{
AddInInstalled.Indicator = Properties.Resources.Runing;
_state = State.WaitingForInstaller;
int exitCode = RunProcess(_downloadedFile, "");
RegistryHelper.WriteAction($"Chem4Word ExitCode: {exitCode}");
if (exitCode == 0)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(RegistryKeyName, true);
if (key == null)
{
key = Registry.CurrentUser.CreateSubKey(RegistryKeyName);
}
if (key != null)
{
try
{
// Erase previously stored Update Checks etc
foreach (string keyName in key.GetSubKeyNames())
{
key.DeleteValue(keyName);
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
progressBar1.Value = 0;
progressBar1.Maximum = 100;
progressBar1.Value = 100;
AddInInstalled.Indicator = Properties.Resources.Yes;
Information.Text = "Chem4Word successfully installed. Please start Microsoft Word, then select Chemistry Tab in ribbon";
Action.Text = "Finish";
}
else
{
AddInInstalled.Indicator = Properties.Resources.No;
Information.Text = $"Error installing Chem4Word; ExitCode: {exitCode}";
Action.Text = "Exit";
_state = State.Done;
}
}
catch (Exception ex)
{
Information.Text = ex.Message;
Debug.WriteLine(ex.Message);
Action.Text = "Exit";
}
Action.Enabled = true;
timer1.Enabled = false;
_state = State.Done;
break;
case State.WaitingForInstaller:
break;
case State.Done:
timer1.Enabled = false;
Action.Enabled = true;
break;
}
}
19
Source : SettingsWindow.xaml.cs
with GNU General Public License v3.0
from CodeDead
with GNU General Public License v3.0
from CodeDead
private void ResetSettings()
{
_logController.AddLog(new ApplicationLog("Resetting properties"));
try
{
if (Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "MemPlus", "").ToString() != "")
{
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true))
{
key?.DeleteValue("MemPlus");
}
}
Properties.Settings.Default.Reset();
Properties.Settings.Default.Save();
_mainWindow.ChangeVisualStyle();
_mainWindow.LoadProperties();
_mainWindow.LoadLanguage();
_mainWindow.HotKeyModifier(new WindowInteropHelper(_mainWindow));
_logController.SetAutoClear(Properties.Settings.Default.LogClearAuto);
_logController.SetAutoClearInterval(Properties.Settings.Default.LogClearInterval);
_logController.SetSaveToFile(Properties.Settings.Default.SaveLogsToFile);
ChangeVisualStyle();
LoadProperties();
_logController.AddLog(new ApplicationLog("Properties have been reset"));
MessageBox.Show((string)Application.Current.FindResource("ResetAllSettings"), "MemPlus", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
_logController.AddLog(new ErrorLog(ex.Message));
MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
19
Source : SettingsWindow.xaml.cs
with GNU General Public License v3.0
from CodeDead
with GNU General Public License v3.0
from CodeDead
private void SaveProperties()
{
_logController.AddLog(new ApplicationLog("Saving properties"));
try
{
// General
if (ChbAutoStart.IsChecked != null && ChbAutoStart.IsChecked.Value)
{
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "MemPlus", System.Reflection.replacedembly.GetExecutingreplacedembly().Location);
}
else if (ChbAutoStart.IsChecked != null && !ChbAutoStart.IsChecked.Value)
{
if (Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "MemPlus", "").ToString() != "")
{
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true))
{
key?.DeleteValue("MemPlus");
}
}
}
// Logging
_logController.SetLoggingEnabled(Properties.Settings.Default.LoggingEnabled);
_logController.SetAutoClear(Properties.Settings.Default.LogClearAuto);
Properties.Settings.Default.LogClearIntervalIndex = CboLogClearInterval.SelectedIndex;
if (ItbAutoClearLogsInterval.Value != null)
{
int logInterval = (int) ItbAutoClearLogsInterval.Value;
// ReSharper disable once SwitchStatementMissingSomeCases
switch (CboLogClearInterval.SelectedIndex)
{
case 1:
logInterval = logInterval * 1000;
break;
case 2:
logInterval = logInterval * 1000 * 60;
break;
case 3:
logInterval = logInterval * 1000 * 60 * 60;
break;
}
Properties.Settings.Default.LogClearInterval = logInterval;
_logController.SetAutoClearInterval(logInterval);
}
if (Properties.Settings.Default.SaveLogsToFile && Properties.Settings.Default.LogPath.Length == 0)
{
Properties.Settings.Default.SaveLogsToFile = false;
}
if (Properties.Settings.Default.LogPath.Length > 0)
{
_logController.SetSaveDirectory(Properties.Settings.Default.LogPath);
}
/*
* Make sure this is the last LogController method that is called when saving the settings
* because this will only work properly when all other settings (especially the directory)
* have been set correctly
*/
_logController.SetSaveToFile(Properties.Settings.Default.SaveLogsToFile);
// RAM Monitor
Properties.Settings.Default.RamMonitorIntervalIndex = CboRamMonitorInterval.SelectedIndex;
if (ItbRamMonitorTimeout.Value != null)
{
int ramInterval = (int)ItbRamMonitorTimeout.Value;
// ReSharper disable once SwitchStatementMissingSomeCases
switch (CboRamMonitorInterval.SelectedIndex)
{
case 1:
ramInterval = ramInterval * 1000;
break;
case 2:
ramInterval = ramInterval * 1000 * 60;
break;
case 3:
ramInterval = ramInterval * 1000 * 60 * 60;
break;
}
Properties.Settings.Default.RamMonitorInterval = ramInterval;
}
Properties.Settings.Default.AutoOptimizeTimedIntervalIndex = CboAutoOptimizeTimedIndex.SelectedIndex;
if (ItbAutoOptimizeTimed.Value != null)
{
switch (CboAutoOptimizeTimedIndex.SelectedIndex)
{
default:
Properties.Settings.Default.AutoOptimizeTimedInterval = (int)ItbAutoOptimizeTimed.Value * 1000 * 60;
break;
case 1:
Properties.Settings.Default.AutoOptimizeTimedInterval = (int)ItbAutoOptimizeTimed.Value * 1000 * 60 * 60;
break;
}
}
// RAM Optimizer
List<string> exclusionList = LsvExclusions.Items.Cast<string>().ToList();
Properties.Settings.Default.ProcessExceptions = exclusionList;
Properties.Settings.Default.HotKey = _hotKey;
Properties.Settings.Default.HotKeyModifiers = _hotKeyModifiers;
// Theme
Properties.Settings.Default.Save();
_mainWindow.ChangeVisualStyle();
_mainWindow.LoadProperties();
_mainWindow.LoadLanguage();
_mainWindow.HotKeyModifier(new WindowInteropHelper(_mainWindow));
ChangeVisualStyle();
LoadProperties();
_logController.AddLog(new ApplicationLog("Properties have been saved"));
MessageBox.Show((string)Application.Current.FindResource("SavedAllSettings"), "MemPlus", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
_logController.AddLog(new ErrorLog(ex.Message));
MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
19
Source : IEHelper.cs
with Apache License 2.0
from cqjjjzr
with Apache License 2.0
from cqjjjzr
public static void EnsureBrowserEmulationEnabled(string exename, bool uninstall = false)
{
var current = GetInternetExplorerMajorVersion();
if (current < 11) throw new IeVersionTooOldException();
var rk = Registry.CurrentUser.OpenSubKey(
@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true) ??
Registry.CurrentUser.CreateSubKey(
@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true);
if (!uninstall)
{
dynamic value = rk.GetValue(exename);
if (value == null)
rk.SetValue(exename, (uint)0x2AF9, RegistryValueKind.DWord); // Use IE11
}
else
rk.DeleteValue(exename);
rk.Dispose();
}
19
Source : Register.cs
with GNU General Public License v3.0
from cymheart
with GNU General Public License v3.0
from cymheart
public virtual bool DeleteRegeditKey()
{
///删除结果
bool result = false;
///判断是否设置键值属性,如果没有设置,则返回false
if (_regeditkey == string.Empty || _regeditkey == null)
{
return false;
}
///判断键值是否存在
if (IsRegeditKeyExist())
{
///以可写方式打开注册表项
RegistryKey key = OpenSubKey(true);
if (key != null)
{
try
{
///删除键值
key.DeleteValue(_regeditkey);
result = true;
}
catch
{
result = false;
}
finally
{
///关闭对注册表项的更改
key.Close();
}
}
}
return result;
}
19
Source : RegTests.cs
with MIT License
from dahall
with MIT License
from dahall
[Test]
public void TestRegMonitor()
{
const string subkey = @"Software\Vanara";
const string subkey2 = "Test";
var m = new RegistryEventMonitor { RegistryKeyName = @"HKEY_CURRENT_USER\" + subkey, IncludeSubKeys = true };
var ev1 = new AutoResetEvent(false);
var ev2 = new AutoResetEvent(false);
m.ValueChanged += (s, e) => { TestContext.WriteLine("Value changed."); ev1.Set(); };
m.SubkeyChanged += (s, e) => { TestContext.WriteLine("Subkey changed."); ev2.Set(); };
m.EnableRaisingEvents = true;
using (var k = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(subkey, true))
{
var sk = k.CreateSubKey(subkey2);
sk.SetValue("uint", 2U, Microsoft.Win32.RegistryValueKind.DWord);
sk.DeleteValue("uint");
replacedert.That(WaitHandle.WaitAll(new WaitHandle[] { ev1, ev2 }, 5000));
m.IncludeSubKeys = false;
replacedert.That(m.EnableRaisingEvents, Is.False);
ev1.Reset();
m.EnableRaisingEvents = true;
k.SetValue("uint", 2U, Microsoft.Win32.RegistryValueKind.DWord);
k.DeleteValue("uint");
replacedert.That(ev1.WaitOne(100));
ev1.Reset();
sk.SetValue("uint", 2U, Microsoft.Win32.RegistryValueKind.DWord);
replacedert.That(ev1.WaitOne(100), Is.False);
ev2.Reset();
k.DeleteSubKey(subkey2);
replacedert.That(ev2.WaitOne(1000));
}
}
19
Source : RegistryExtensions.cs
with MIT License
from dahall
with MIT License
from dahall
public static bool DeleteAllSubItems(this RegistryKey key)
{
var succeeded = true;
foreach (var n in key.GetSubKeyNames())
try { key.DeleteSubKeyTree(n); } catch { succeeded = false; }
foreach (var n in key.GetValueNames())
key.DeleteValue(n);
return succeeded;
}
19
Source : AutostartHelper.cs
with MIT License
from davidvidmar
with MIT License
from davidvidmar
public static void Clear()
{
registryKey.DeleteValue(replacedembly.GetEntryreplacedembly().GetName().Name);
}
19
Source : RenameRegValueAction.cs
with MIT License
from DCourtel
with MIT License
from DCourtel
public override void Run(ref ReturnCodeAction returnCode)
{
Logger.Write("Running RenameRegValueAction. Hive = " + this.Hive + " and RegKey = " + this.RegKey + " UseReg32 = " + this.UseReg32.ToString() + " ValueName = " + ValueName + " NewName = " + NewName);
try
{
RegistryKey hiveKey;
switch (this.Hive)
{
case "HKey_Current_User":
hiveKey = Registry.CurrentUser; // Il n'y a pas de notion de registre 32bit ou 64bit dans la ruche CURRENT_USER
break;
case "HKey_Local_Machine":
hiveKey = this.UseReg32 ? RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32) : RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
break;
default:
throw new Exception("The Hive is not recognized.");
}
RegistryKey targetKey;
targetKey = hiveKey.OpenSubKey(RegKey, true);
if(targetKey !=null)
{
RegistryValueKind valueKind = targetKey.GetValueKind(this.ValueName);
object data = targetKey.GetValue(this.ValueName);
targetKey.SetValue(this.NewName, data, valueKind); // Creating the new value
targetKey.DeleteValue(this.ValueName); // Deleting the old value
targetKey.Close();
hiveKey.Close();
}
else
{
Logger.Write("The registryKey " + this.RegKey + " doesn't exists.");
}
}
catch (Exception ex)
{
Logger.Write("**** An error occurs : " + ex.Message);
}
Logger.Write("End of RenameRegValueAction.");
}
19
Source : Reg1c1de.cs
with GNU General Public License v3.0
from deadjakk
with GNU General Public License v3.0
from deadjakk
static void writetest(RegistryKey key)
{
//double checking
if (key.Name.Contains(uniquestring))
{
return;
}
RegistryKey nkey = key.CreateSubKey(uniquestring, true); // unique string
nkey.SetValue("dead", "jakk");
iprint("[+]successfully wrote a key to " + key.Name);
try
{
iprint("Removing key we created: " + nkey.Name);
foreach (String value in nkey.GetValueNames())
{
nkey.DeleteValue(value);
}
key.DeleteSubKey(uniquestring);
iprint("key successfully removed");
}
catch
{
Console.WriteLine("[!]Error deleting key {0}\tFOLLOW-UP", nkey.Name);
fails.Add(nkey.Name);
}
}
19
Source : Config.cs
with GNU Lesser General Public License v3.0
from DigiByteMiner
with GNU Lesser General Public License v3.0
from DigiByteMiner
public void SetLaunchOnStartup(bool set)
{
try
{
string regKeystr = "DigibyteMiner";
RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if(set)
{
if (rkApp.GetValue(regKeystr) != null)
{
rkApp.DeleteValue(regKeystr);
}
rkApp.SetValue(regKeystr, Application.ExecutablePath);
}
else
{
if (rkApp.GetValue(regKeystr) == null)
{
//Logger.Instance.LogInfo("Item is not there in startup anyway");
}
else
{
rkApp.DeleteValue(regKeystr, false);
}
}
}
catch (Exception e)
{
Logger.Instance.LogInfo(e.ToString());
}
}
19
Source : Extension.cs
with Microsoft Public License
from Dijji
with Microsoft Public License
from Dijji
private void RemovePropertyHandler()
{
#if x64
// On 64-bit machines, remove the 32-bit property handler, as we set up both
using (RegistryKey handlers = RegistryExtensions.OpenBaseKey(RegistryHive.LocalMachine, RegistryExtensions.RegistryHiveType.X86).
OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\PropertySystem\PropertyHandlers", true))
{
bool delete = false;
using (RegistryKey handler = handlers.OpenSubKey(Name, true))
{
if (handler != null)
{
if (handler.GetValueNames().Contains(ChainedValueName))
{
var temp = handler.GetValue(ChainedValueName);
handler.SetValue(null, temp);
handler.DeleteValue(ChainedValueName);
}
else
{
// Only delete the sub key if it points to our handler
var temp = handler.GetValue(null) as string;
delete = (temp != null && temp == OurPropertyHandlerGuid32);
}
}
}
// Delete needs to happen after we have released the registry key
if (delete)
handlers.DeleteSubKey(Name);
}
#endif
// Now, remove the main handler extension key, which is 32- or 64-bit, depending on how we were built
// The 32-bit and 64-bit values of these are separate and isolated on 64-bit Windows,
// the 32-bit value being under SOFTWARE\Wow6432Node. Thus a 64-bit manager is needed to set up a 64-bit handler
using (RegistryKey handlers = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\PropertySystem\PropertyHandlers", true))
{
if (PropertyHandlerState == HandlerState.Ours)
{
handlers.DeleteSubKey(Name);
this.RecordPropertyHandler(HandlerState.None, null, null);
}
else if (PropertyHandlerState == HandlerState.Chained)
{
using (RegistryKey handler = handlers.OpenSubKey(Name, true))
{
handler.SetValue(null, PropertyHandlerGuid);
handler.DeleteValue(ChainedValueName);
this.RecordPropertyHandler(HandlerState.Foreign, PropertyHandlerGuid, PropertyHandlerreplacedle);
}
}
}
}
19
Source : Extension.cs
with Microsoft Public License
from Dijji
with Microsoft Public License
from Dijji
private void GetAndHidePreExistingProgidRegistryEntries(RegistryKey target, Profile profile)
{
if (target == null)
return;
// We only have to hide existing Profile Detail entries, as context menus are additive
var val = target.GetValue(FullDetailsValueName);
if (val != null)
{
target.SetValue(OldFullDetailsValueName, val);
target.DeleteValue(FullDetailsValueName);
if (profile != null)
profile.FullDetailsString = val as string;
}
val = target.GetValue(InfoTipValueName);
if (val != null)
{
target.SetValue(OldInfoTipValueName, val);
target.DeleteValue(InfoTipValueName);
if (profile != null)
profile.InfoTipString = val as string;
}
val = target.GetValue(PreviewDetailsValueName);
if (val != null)
{
target.SetValue(OldPreviewDetailsValueName, val);
target.DeleteValue(PreviewDetailsValueName);
if (profile != null)
profile.PreviewDetailsString = val as string;
}
}
See More Examples