1.1 --- a/GUI/StartupManager.cs Mon Sep 13 22:55:25 2010 +0000
1.2 +++ b/GUI/StartupManager.cs Tue Sep 14 19:23:11 2010 +0000
1.3 @@ -174,7 +174,7 @@
1.4 }
1.5
1.6 private void CreateRegistryRun() {
1.7 - RegistryKey key = Registry.CurrentUser.CreateSubKey(REGISTRY_RUN);
1.8 + RegistryKey key = Registry.CurrentUser.CreateSubKey(REGISTRY_RUN);
1.9 key.SetValue("OpenHardwareMonitor", Application.ExecutablePath);
1.10 }
1.11
1.12 @@ -192,20 +192,27 @@
1.13 return startup;
1.14 }
1.15 set {
1.16 - if (startup != value) {
1.17 - startup = value;
1.18 + if (startup != value) {
1.19 if (isAvailable) {
1.20 if (scheduler != null) {
1.21 - if (startup)
1.22 + if (value)
1.23 CreateSchedulerTask();
1.24 else
1.25 DeleteSchedulerTask();
1.26 + startup = value;
1.27 } else {
1.28 - if (startup)
1.29 - CreateRegistryRun();
1.30 - else
1.31 - DeleteRegistryRun();
1.32 + try {
1.33 + if (value)
1.34 + CreateRegistryRun();
1.35 + else
1.36 + DeleteRegistryRun();
1.37 + startup = value;
1.38 + } catch (UnauthorizedAccessException) {
1.39 + throw new InvalidOperationException();
1.40 + }
1.41 }
1.42 + } else {
1.43 + throw new InvalidOperationException();
1.44 }
1.45 }
1.46 }