Skip to content

Commit

Permalink
CatchRegistryKey
Browse files Browse the repository at this point in the history
  • Loading branch information
juancramos committed Dec 20, 2017
1 parent 6c715fd commit 5341c7e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Tulpep.NetworkAutoSwitch.ProxyService/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,22 @@ private static void StartService(string serviceName, int timeoutMilliseconds, Pr
service.Start(new string[] { "-p", priority.ToString() });
service.WaitForStatus(ServiceControllerStatus.Running, timeout);
Logging.WriteConsoleMessage("Service running");
using (RegistryKey hkcu = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64))

try
{
using (RegistryKey proxyAutoSwitch = hkcu.CreateSubKey(Constants.KEY_CONFIG_PATH, RegistryKeyPermissionCheck.Default))
using (RegistryKey hkcu = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64))
{
string config = priority == Priority.Wired ? Decimal.One.ToString() : Decimal.Zero.ToString();
proxyAutoSwitch.SetValue(Constants.KEY_CONFIG_NAME, config, RegistryValueKind.String);
using (RegistryKey proxyAutoSwitch = hkcu.CreateSubKey(Constants.KEY_CONFIG_PATH, RegistryKeyPermissionCheck.Default))
{
string config = priority == Priority.Wired ? Decimal.One.ToString() : Decimal.Zero.ToString();
proxyAutoSwitch.SetValue(Constants.KEY_CONFIG_NAME, config, RegistryValueKind.String);
}
}
}
catch (Exception e)
{
Logging.WriteMessageEventViewerError(Constants.SERVICE_NAME, e.Message);
}
}

private static void ExtractProxyEnabler()
Expand Down

0 comments on commit 5341c7e

Please sign in to comment.