ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/AnywhereTS-MSSQL/trunk/TSControlPanel/CPanel.Installer.cs
Revision: 184
Committed: Mon Jul 16 14:05:59 2012 UTC (10 years, 10 months ago) by william
File size: 5011 byte(s)
Log Message:
remove duplicated registry registry

File Contents

# Content
1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4 using System.ComponentModel;
5 using System.Configuration.Install;
6 using System.Linq;
7
8
9 namespace AnywhereTS
10 {
11 [RunInstaller(true)]
12 public partial class CPanel : System.Configuration.Install.Installer
13 {
14 public CPanel()
15 {
16 InitializeComponent();
17 }
18 #region install
19 public override void Install(IDictionary stateSaver)
20 {
21 base.Install(stateSaver);
22 string path = this.Context.Parameters["targetdir"];
23 Logging.UpdateLogPath(string.Format(@"{0}\logs", path));
24 using (log4net.NDC.Push("Logged from TSControlPanel.Installer"))
25 {
26 try
27 {
28 CreateRegistryConfigKeys();
29 }
30 catch (Exception ex)
31 {
32 using (log4net.NDC.Push(string.Format("{0}: MESSAGE={1}{2}Diagnostics:{2}{3}", ex.GetType().Name, ex.Message, System.Environment.NewLine, ex.ToString())))
33 {
34 Logging.TSControlPanelInstallerLog.Error("Install() failed.");
35 }
36 throw ex;
37 }
38 }
39 }
40 private void CreateRegistryConfigKeys()
41 {
42 try
43 {
44 Logging.TSControlPanelInstallerLog.Info("Creating AnywhereTS Control Panel registry settings");
45 Microsoft.Win32.RegistryKey key = null;
46 if (IntPtr.Size == 8)
47 { // 64 bit OS
48 //string t = @"SOFTWARE\Wow6432Node\" + ATSGlobals.ApplicationName + @"\ts-config";
49 key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\", true);
50 key = key.CreateSubKey(ATSGlobals.ApplicationName).CreateSubKey("ts-config");
51 }
52 else
53 { // 32 bit OS
54 //strATSregRoot = @"SOFTWARE\" + ATSGlobals.ApplicationName + @"\ts-config";
55 key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software", true);
56 key = key.CreateSubKey(ATSGlobals.ApplicationName).CreateSubKey("ts-config");
57 }
58
59 // AdminVersion = 2
60 key.SetValue("ControlPanelVersion", 1);
61 // RunFirstTime = 1
62 key.SetValue("RunFirstTime", 1);
63 ATSGlobals.CreateRegistryValues();
64 Logging.TSControlPanelInstallerLog.Info("Successfully created AnywhereTS Control Panel registry settings");
65 }
66 catch (Exception ex)
67 {
68 using (log4net.NDC.Push(string.Format("{0}: MESSAGE={1}{2}Diagnostics:{2}{3}", ex.GetType().Name, ex.Message, System.Environment.NewLine, ex.ToString())))
69 {
70 Logging.TSControlPanelInstallerLog.Error("CreateRegistryConfigKeys() failed.");
71 }
72 }
73 }
74 #endregion
75 #region uninstall
76 public override void Uninstall(IDictionary savedState)
77 {
78 using (log4net.NDC.Push("Logged from TSControlPanel.Installer"))
79 {
80 try
81 {
82 string path = this.Context.Parameters["targetdir"];
83 Logging.UpdateLogPath(string.Format(@"{0}\logs", path));
84 Logging.TSControlPanelInstallerLog.DebugFormat("Removing TSControlPanel Registry settings");
85 Microsoft.Win32.RegistryKey key = null;
86 if (IntPtr.Size == 8)
87 { // 64 bit OS
88 //string t = @"SOFTWARE\Wow6432Node\" + ATSGlobals.ApplicationName + @"\ts-config";
89 key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(string.Format(@"SOFTWARE\Wow6432Node\{0}\{1}", ATSGlobals.ApplicationName,"ts-config"), true);
90 key.DeleteValue("ControlPanelVersion",false);
91 }
92 else
93 { // 32 bit OS
94 //strATSregRoot = @"SOFTWARE\" + ATSGlobals.ApplicationName + @"\ts-config";
95 key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(string.Format(@"Software\{0}\{1}", ATSGlobals.ApplicationName, "ts-config"), true);
96 key.DeleteValue("ControlPanelVersion",false);
97 }
98 Logging.TSControlPanelInstallerLog.DebugFormat("Successfully removed TSControlPanel Registry settings");
99 }
100 catch (Exception ex)
101 {
102 Logging.TSControlPanelInstallerLog.DebugFormat("Failed to remove TSControlPanel Registry settings");
103 throw ex;
104 }
105 }
106 }
107 #endregion
108 }
109 }