private void OnConfigurationChanged(object sender, ConfigurationChangedEventArgs args) { communicationManager.UpdateService(args.Configuration.Host, args.Configuration.Port); ResourceManager.Instance.Culture = new System.Globalization.CultureInfo(configuration.Configuration.Language); this.UpdateResources(); //Kill daemon and remove from startup if (!args.Configuration.AutoDetectMessages) { RegistryKey key = Registry.LocalMachine.CreateSubKey("init"); if (key.GetValue("Launch99") != null) { key.DeleteValue("Launch99"); } key.Close(); if (daemonPid == -1) { try { daemonPid = (int)Registry.LocalMachine.OpenSubKey(@"Floading\MobileListener\ListenerPid\").GetValue("Pid"); } catch (Exception) { } } if (daemonPid != -1) { //Kill the process, and store the "no-process" identificator in the registry Process.GetProcessById(daemonPid).Kill(); daemonPid = -1; Registry.LocalMachine.CreateSubKey(@"Floading\MobileListener\ListenerPid\").SetValue("Pid", -1); } checkNewButton.Visible = false; } else { if (daemonPid == -1) { RegistryKey key = Registry.LocalMachine.CreateSubKey("init"); key.SetValue("Launch99", Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\" + Mobile.Properties.Resources.MobileListenerExecutable); key.Close(); String mobilePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase); String daemonAppPath = mobilePath + @"\\" + Mobile.Properties.Resources.MobileListenerExecutable; Process proc = Process.Start(new ProcessStartInfo(daemonAppPath, "")); daemonPid = proc.Id; } checkNewButton.Visible = true; } if (settingsScreen != null) { settingsScreen.ConfigurationChanged -= OnConfigurationChanged; settingsScreen.Close(); } }