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 |
|
|
using (log4net.NDC.Push("Logged from TSControlPanel.Installer")) |
22 |
|
|
{ |
23 |
|
|
CreateRegistryConfigKeys(); |
24 |
|
|
} |
25 |
|
|
} |
26 |
|
|
private void CreateRegistryConfigKeys() |
27 |
|
|
{ |
28 |
|
|
try |
29 |
|
|
{ |
30 |
|
|
Microsoft.Win32.RegistryKey key = null; |
31 |
|
|
if (IntPtr.Size == 8) |
32 |
|
|
{ // 64 bit OS |
33 |
|
|
//string t = @"SOFTWARE\Wow6432Node\" + ATSGlobals.ApplicationName + @"\ts-config"; |
34 |
|
|
key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\", true); |
35 |
|
|
key = key.CreateSubKey(ATSGlobals.ApplicationName).CreateSubKey("ts-config"); |
36 |
|
|
} |
37 |
|
|
else |
38 |
|
|
{ // 32 bit OS |
39 |
|
|
//strATSregRoot = @"SOFTWARE\" + ATSGlobals.ApplicationName + @"\ts-config"; |
40 |
|
|
key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software", true); |
41 |
|
|
key = key.CreateSubKey(ATSGlobals.ApplicationName).CreateSubKey("ts-config"); |
42 |
|
|
} |
43 |
|
|
|
44 |
|
|
// AdminVersion = 2 |
45 |
|
|
key.SetValue("ControlPanelVersion", 1); |
46 |
|
|
// RunFirstTime = 1 |
47 |
|
|
key.SetValue("RunFirstTime", 1); |
48 |
|
|
ATSGlobals.CreateRegistryValues(); |
49 |
|
|
} |
50 |
|
|
catch (Exception ex) |
51 |
|
|
{ |
52 |
|
|
using (log4net.NDC.Push(string.Format("{0}: MESSAGE={1}{2}Diagnostics:{2}{3}", ex.GetType().Name, ex.Message, System.Environment.NewLine, ex.ToString()))) |
53 |
|
|
{ |
54 |
|
|
Logging.TSControlPanelInstallerLog.Error("CreateRegistryConfigKeys() failed."); |
55 |
|
|
} |
56 |
|
|
} |
57 |
|
|
} |
58 |
|
|
#endregion |
59 |
|
|
#region uninstall |
60 |
|
|
public override void Uninstall(IDictionary savedState) |
61 |
|
|
{ |
62 |
|
|
using (log4net.NDC.Push("Logged from TSControlPanel.Installer")) |
63 |
|
|
{ |
64 |
|
|
try |
65 |
|
|
{ |
66 |
|
|
Logging.TSControlPanelInstallerLog.DebugFormat("Removing TSControlPanel Registry settings"); |
67 |
|
|
Microsoft.Win32.RegistryKey key = null; |
68 |
|
|
if (IntPtr.Size == 8) |
69 |
|
|
{ // 64 bit OS |
70 |
|
|
//string t = @"SOFTWARE\Wow6432Node\" + ATSGlobals.ApplicationName + @"\ts-config"; |
71 |
|
|
key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(string.Format(@"SOFTWARE\Wow6432Node\{0}\{1}", ATSGlobals.ApplicationName,"ts-config"), true); |
72 |
|
|
key.DeleteValue("ControlPanelVersion",false); |
73 |
|
|
} |
74 |
|
|
else |
75 |
|
|
{ // 32 bit OS |
76 |
|
|
//strATSregRoot = @"SOFTWARE\" + ATSGlobals.ApplicationName + @"\ts-config"; |
77 |
|
|
key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(string.Format("Software\{0}\{1}", ATSGlobals.ApplicationName, "ts-config"), true); |
78 |
|
|
key.DeleteValue("ControlPanelVersion",false); |
79 |
|
|
} |
80 |
|
|
Logging.TSControlPanelInstallerLog.DebugFormat("Successfully removed TSControlPanel Registry settings"); |
81 |
|
|
} |
82 |
|
|
catch (Exception ex) |
83 |
|
|
{ |
84 |
|
|
Logging.TSControlPanelInstallerLog.DebugFormat("Failed to remove TSControlPanel Registry settings"); |
85 |
|
|
throw ex; |
86 |
|
|
} |
87 |
|
|
} |
88 |
|
|
} |
89 |
|
|
#endregion |
90 |
william |
145 |
} |
91 |
|
|
} |