public void Uninstall()
        {
            DotNetServiceInstaller installer = new DotNetServiceInstaller();
            ServiceInstallInfo installInfo = new ServiceInstallInfo();

            installInfo.ServiceName = ServiceName;
            installInfo.DisplayName = DisplayName;
            installInfo.Description = Description;

            try
            {
                installer.UnInstall(installInfo);
                MessageBox.Show("卸载完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("对不起,卸载失败!\r\n原因:{0}", ex.ToString()));
            }
        }
        public void Uninstall()
        {
            DotNetServiceInstaller installer   = new DotNetServiceInstaller();
            ServiceInstallInfo     installInfo = new ServiceInstallInfo();

            installInfo.ServiceName = ServiceName;
            installInfo.DisplayName = DisplayName;
            installInfo.Description = Description;

            try
            {
                installer.UnInstall(installInfo);
                MessageBox.Show("卸载完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("对不起,卸载失败!\r\n原因:{0}", ex.ToString()));
            }
        }
        public void Install()
        {
            DotNetServiceInstaller installer = new DotNetServiceInstaller();
            ServiceInstallInfo installInfo = new ServiceInstallInfo();
            // -service
            installInfo.ServiceFilePath = $"\"{Assembly.GetEntryAssembly().Location}\" -service";
            installInfo.ServiceName = ServiceName;
            installInfo.DisplayName = DisplayName;
            installInfo.Description = Description;
            installInfo.StartType = ServiceStartMode.Automatic;

            installInfo.IfDelayedAutoStart = true;
            installInfo.ServiceAccount.Account = ServiceAccount.LocalSystem;
            try
            {
                installer.Install(installInfo);
                MessageBox.Show("安装完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("对不起,安装失败!\r\n原因:{0}", ex.ToString()));
            }
        }
        public void Install()
        {
            DotNetServiceInstaller installer   = new DotNetServiceInstaller();
            ServiceInstallInfo     installInfo = new ServiceInstallInfo();

            // -service
            installInfo.ServiceFilePath = $"\"{Assembly.GetEntryAssembly().Location}\" -service";
            installInfo.ServiceName     = ServiceName;
            installInfo.DisplayName     = DisplayName;
            installInfo.Description     = Description;
            installInfo.StartType       = ServiceStartMode.Automatic;

            installInfo.IfDelayedAutoStart     = true;
            installInfo.ServiceAccount.Account = ServiceAccount.LocalSystem;
            try
            {
                installer.Install(installInfo);
                MessageBox.Show("安装完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("对不起,安装失败!\r\n原因:{0}", ex.ToString()));
            }
        }