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, 8 months ago) by william
File size: 5011 byte(s)
Log Message:
remove duplicated registry registry

File Contents

# User Rev Content
1 william 145 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 william 166 #region install
19     public override void Install(IDictionary stateSaver)
20     {
21 william 167 base.Install(stateSaver);
22     string path = this.Context.Parameters["targetdir"];
23     Logging.UpdateLogPath(string.Format(@"{0}\logs", path));
24 william 166 using (log4net.NDC.Push("Logged from TSControlPanel.Installer"))
25     {
26 william 167 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 william 166 }
39     }
40     private void CreateRegistryConfigKeys()
41     {
42     try
43     {
44 william 183 Logging.TSControlPanelInstallerLog.Info("Creating AnywhereTS Control Panel registry settings");
45 william 166 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 william 184 Logging.TSControlPanelInstallerLog.Info("Successfully created AnywhereTS Control Panel registry settings");
65 william 166 }
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 william 167 string path = this.Context.Parameters["targetdir"];
83     Logging.UpdateLogPath(string.Format(@"{0}\logs", path));
84 william 166 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 william 167 key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(string.Format(@"Software\{0}\{1}", ATSGlobals.ApplicationName, "ts-config"), true);
96 william 166 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 william 145 }
109     }