public ServerServiceProcess(string systemId)
 {
     // This call is required by the Windows.Forms Component Designer.
     InitializeComponent();
     this.systemId    = systemId;
     this.ServiceName = ServerServiceProcess.GetServiceName(systemId);
 }
        public override void Uninstall(IDictionary savedState)
        {
            if (Context != null)
            {
                if (Context.Parameters.Count > 0)
                {
                    String systemId = Context.Parameters["systemid"];
                    if ((systemId != null) && (systemId != ""))
                    {
                        this.serviceInstaller.ServiceName = ServerServiceProcess.GetServiceName(systemId);
                        this.serviceInstaller.DisplayName = this.serviceInstaller.ServiceName;
                    }
                }
            }

            // call the original Install() method to create root key
            base.Uninstall(savedState);
        }
        public override void Install(IDictionary savedState)
        {
            String systemId = "";

            if (Context != null)
            {
                if (Context.Parameters.Count > 0)
                {
                    systemId = Context.Parameters["systemid"];

                    if ((systemId != null) && (systemId != ""))
                    {
                        this.serviceInstaller.ServiceName = ServerServiceProcess.GetServiceName(systemId);
                        this.serviceInstaller.DisplayName = this.serviceInstaller.ServiceName;
                    }
                }
            }

            // call the original Install() method to create root key
            base.Install(savedState);

            Microsoft.Win32.RegistryKey ServiceDescription = null;
            try
            {
                ServiceDescription =
                    Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\Services\" + serviceInstaller.ServiceName, true);

                ServiceDescription.SetValue("Description", ServerServiceProcess.GetServiceDescription(systemId));
                if ((systemId != null) && (systemId != ""))
                {
                    string imagePath = ServiceDescription.GetValue("ImagePath") as string;
                    ServiceDescription.SetValue("ImagePath", string.Format("{0} {1}", imagePath, systemId));
                }

                ServiceDescription.Close();
            }
            catch (Exception)
            {
            }
        }