public void startup() { RegistryKey rk = Registry.CurrentUser; RegistryKey StartupPath; StartupPath = rk.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (StartupPath.GetValue("Workplace") == null) { StartupPath.SetValue("Workplace", Application.ExecutablePath.ToString(), RegistryValueKind.ExpandString); } //RegistryKey reg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); //reg.SetValue("Workplace", Application.ExecutablePath.ToString()); }
public void startup() { RegistryKey rk = Registry.CurrentUser; RegistryKey StartupPath; StartupPath = rk.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (StartupPath.GetValue("Workplace") == null) { StartupPath.SetValue("Workplace", Application.ExecutablePath.ToString(), RegistryValueKind.ExpandString); } this.txtpass.Text = Properties.Settings.Default.password != string.Empty ? Properties.Settings.Default.password : "******"; this.txtname.Text = Properties.Settings.Default.username != string.Empty ? Properties.Settings.Default.username : "******"; //RegistryKey reg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); //reg.SetValue("Workplace", Application.ExecutablePath.ToString()); }
private void CheckRegistry(bool Enable) { RegistryKey rkStartUp = Registry.CurrentUser; RegistryKey StartupPath; string name = "Zorbo Server"; string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AppDomain.CurrentDomain.FriendlyName); StartupPath = rkStartUp.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true); if (Enable && (string)StartupPath.GetValue(name) != path) { StartupPath.SetValue(name, path, RegistryValueKind.ExpandString); } else if (!Enable && StartupPath.GetValue(name) != null) { StartupPath.DeleteValue(name); } }