C#:安装Windows服务,动态指定服务名及描述
2021-04-13 23:26
标签:div init exception otf tar 显示 script pps amp Installer.cs>> 配置类:SettingHelper.cs C#:安装Windows服务,动态指定服务名及描述 标签:div init exception otf tar 显示 script pps amp 原文地址:https://www.cnblogs.com/amylis_chen/p/8971969.htmlpublic Installer()
{
InitializeComponent();
/* 服务未注册前,System.Configuration.ConfigurationManager.AppSettings读取无效。
//serviceInstaller1.ServiceName = "ChinaHN.XHService." + System.Configuration.ConfigurationManager.AppSettings["Service_ID"];
//serviceInstaller1.DisplayName = System.Configuration.ConfigurationManager.AppSettings["Service_DisplayName"];
//serviceInstaller1.Description = System.Configuration.ConfigurationManager.AppSettings["Service_Description"];
*/
/* 指定该服务的启动模式:自动,手动,禁用
serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.;
*/
using (SettingHelper setting = new SettingHelper())
{
//系统用于标志此服务名称(唯一性)
serviceInstaller1.ServiceName = setting.ServiceName;
//向用户标志服务的显示名称(可以重复)
serviceInstaller1.DisplayName = setting.DisplayName;
//服务的说明(描述)
serviceInstaller1.Description = setting.Description;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
using System.IO;
using System.Xml;
//-------------------------------------
// 描述:初始化服务配置帮助类
// 作者:fooo
// 完成时间:2013-12-16
//-------------------------------------
namespace XHService
{
public class SettingHelper : IDisposable
{
#region 私有成员
private string _ServiceName;
private string _DisplayName;
private string _Description;
#endregion
#region 构造函数
///
文章标题:C#:安装Windows服务,动态指定服务名及描述
文章链接:http://soscw.com/index.php/essay/75399.html