Skip to content

Commit

Permalink
Handle reg key properly on exe move
Browse files Browse the repository at this point in the history
  • Loading branch information
Xeroday committed May 22, 2016
1 parent eb2de97 commit ed54064
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions EZBlocker/EZBlocker/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -580,11 +580,18 @@ private void Main_Load(object sender, EventArgs e)
string hostsFile = File.ReadAllText(hostsPath);
BlockBannersCheckbox.Checked = adHosts.All(host => hostsFile.Contains("0.0.0.0 " + host));
}
object startupKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", false).GetValue("EZBlocker");
if (startupKey != null && startupKey.ToString() == "\"" + Application.ExecutablePath + "\"")
RegistryKey startupKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (startupKey.GetValue("EZBlocker") != null)
{
StartupCheckbox.Checked = true;
this.WindowState = FormWindowState.Minimized;
if (startupKey.GetValue("EZBlocker").ToString() == "\"" + Application.ExecutablePath + "\"")
{
StartupCheckbox.Checked = true;
this.WindowState = FormWindowState.Minimized;
}
else // Reg value exists, but not in right path
{
startupKey.DeleteValue("EZBlocker");
}
}

// Google Analytics
Expand Down

0 comments on commit ed54064

Please sign in to comment.