// Called when the user selects Preferences via hotkey or the Edit menu private void preferences_Click_1(object sender, EventArgs e) { PrefsForm preferencesForm = new PrefsForm(); RegistryKey rkHKCU = Registry.CurrentUser.OpenSubKey("Software"); // Our exception handling will catch a missing subdirectory structure for user preferences // even if we don't make this check, but most of the time if there's no MDi key under // Software we can assume that this is the user's first time going into preferences, so that // should be a good enough check to catch most cases where the user would get the jarring "prefs // not found" error output. if (!rkHKCU.GetSubKeyNames().Contains("MDi")) { preferencesForm.CreateDefault(); } else { preferencesForm.Open(); } rkHKCU.Close(); preferencesForm.ShowDialog(); }