public static void createChangeAccountAndShow() { string domain, username; // First try to load the values from the registry RegistryKey confKey = null; try { confKey = Registry.LocalMachine.OpenSubKey(Constants.REG_CREDS_SUBKEY); if (confKey == null) { MessageBox.Show("Unable to read credentials from registry, maybe you should reinstall this software.", "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } domain = (string)confKey.GetValue("domain"); username = (string)confKey.GetValue("username"); } finally { if (confKey != null) { confKey.Close(); } } ChangeAccount acc = new ChangeAccount(); acc.domainTextBox.Text = domain; acc.usernameTextBox.Text = username; acc.ShowDialog(); }
// !! Event !! private void changeAccountButton_Click(object sender, EventArgs e) { // Check if the service is in stopped state if (this.sc.Status != ServiceControllerStatus.Stopped) { MessageBox.Show("The ProActive Agent must stopped.", "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } // The following will show the account change dialog ChangeAccount.createChangeAccountAndShow(); }