コード例 #1
0
        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()));
            }
        }
コード例 #2
0
        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()));
            }
        }
コード例 #3
0
        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()));
            }
        }
コード例 #4
0
        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()));
            }
        }