ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/AnywhereTS-MSSQL/trunk/TSControlPanel/CPanel.Installer.cs
(Generate patch)

Comparing trunk/TSControlPanel/CPanel.Installer.cs (file contents):
Revision 145 by william, Sun Jul 15 08:34:18 2012 UTC vs.
Revision 166 by william, Mon Jul 16 10:34:12 2012 UTC

--- trunk/TSControlPanel/CPanel.Installer.cs	2012/07/15 08:34:18	145
+++ trunk/TSControlPanel/CPanel.Installer.cs	2012/07/16 10:34:12	166
@@ -15,5 +15,77 @@ namespace AnywhereTS
         {
             InitializeComponent();
         }
+        #region install
+        public override void Install(IDictionary stateSaver)
+        {
+            using (log4net.NDC.Push("Logged from TSControlPanel.Installer"))
+            {
+                CreateRegistryConfigKeys();
+            }
+        }
+        private void CreateRegistryConfigKeys()
+        {
+            try
+            {
+                Microsoft.Win32.RegistryKey key = null;
+                if (IntPtr.Size == 8)
+                {   // 64 bit OS
+                    //string t = @"SOFTWARE\Wow6432Node\" + ATSGlobals.ApplicationName + @"\ts-config";
+                    key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\", true);
+                    key = key.CreateSubKey(ATSGlobals.ApplicationName).CreateSubKey("ts-config");
+                }
+                else
+                {   // 32 bit OS
+                    //strATSregRoot = @"SOFTWARE\" + ATSGlobals.ApplicationName + @"\ts-config";
+                    key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software", true);
+                    key = key.CreateSubKey(ATSGlobals.ApplicationName).CreateSubKey("ts-config");
+                }
+
+                // AdminVersion = 2
+                key.SetValue("ControlPanelVersion", 1);
+                // RunFirstTime = 1
+                key.SetValue("RunFirstTime", 1);
+                ATSGlobals.CreateRegistryValues();
+            }
+            catch (Exception ex)
+            {
+                using (log4net.NDC.Push(string.Format("{0}: MESSAGE={1}{2}Diagnostics:{2}{3}", ex.GetType().Name, ex.Message, System.Environment.NewLine, ex.ToString())))
+                {
+                    Logging.TSControlPanelInstallerLog.Error("CreateRegistryConfigKeys() failed.");
+                }
+            }
+        }
+        #endregion
+        #region uninstall
+        public override void Uninstall(IDictionary savedState)
+        {
+            using (log4net.NDC.Push("Logged from TSControlPanel.Installer"))
+            {
+                try
+                {
+                    Logging.TSControlPanelInstallerLog.DebugFormat("Removing TSControlPanel Registry settings");
+                    Microsoft.Win32.RegistryKey key = null;
+                    if (IntPtr.Size == 8)
+                    {   // 64 bit OS
+                        //string t = @"SOFTWARE\Wow6432Node\" + ATSGlobals.ApplicationName + @"\ts-config";
+                        key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(string.Format(@"SOFTWARE\Wow6432Node\{0}\{1}", ATSGlobals.ApplicationName,"ts-config"), true);
+                        key.DeleteValue("ControlPanelVersion",false);
+                    }
+                    else
+                    {   // 32 bit OS
+                        //strATSregRoot = @"SOFTWARE\" + ATSGlobals.ApplicationName + @"\ts-config";
+                        key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(string.Format("Software\{0}\{1}", ATSGlobals.ApplicationName, "ts-config"), true);
+                        key.DeleteValue("ControlPanelVersion",false);
+                    }
+                    Logging.TSControlPanelInstallerLog.DebugFormat("Successfully removed TSControlPanel Registry settings");
+                }
+                catch (Exception ex)
+                {
+                    Logging.TSControlPanelInstallerLog.DebugFormat("Failed to remove TSControlPanel Registry settings");
+                    throw ex;
+                }
+            }
+        }
+        #endregion
     }
 }