除非在这个windows程序里面设置好,否则一般windows程序是不支持的!
解决方案 »
- datagridview里怎么删除行,不删数据库里的东西
- SQL中用参数化方式添加新字段
- 急:C#结构中数组字符串的解决方法(MarshalAs)
- .Net2.0的setup.exe,有什么工具可以监控安装的时候写注册表和复制什么文件到什么目录呢?
- 如何在控件被拖动以后获取其坐标!!
- (急)关于C#读取CSV文件存储到数据库中的问题.我已经把CSV文件的数据读取到DataSet中了,但是怎么存储到数据库中呢?
- C#DataGridView问题
- 聚合函数sum出错,是不是不能加小数?
- C# 连接带密码的access2007数据库时出错
- 求指点ConcurrentDictionary的用法
- 没有分了,求在.net中使用word控件的方法及那里可以下到这个控件
- 聊天室中,Remoting客户端第二次登录无法收到消息
[RunInstaller(true)] public class Installer1 : System.Configuration.Install.Installer { /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.Container components = null; private System.ServiceProcess.ServiceProcessInstaller spInstaller; private System.ServiceProcess.ServiceInstaller sInstaller; public Installer1() { // 该调用是设计器所必需的。 InitializeComponent(); // TODO: 在 InitComponent 调用后添加任何初始化 } #region Component Designer generated code /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { components = new System.ComponentModel.Container(); // 创建ServiceProcessInstaller对象和ServiceInstaller对象 this.spInstaller = new System.ServiceProcess.ServiceProcessInstaller(); this.sInstaller = new System.ServiceProcess.ServiceInstaller(); // 设定ServiceProcessInstaller对象的帐号、用户名和密码等信息 this.spInstaller.Account = System.ServiceProcess.ServiceAccount.LocalSystem; this.spInstaller.Username = null; this.spInstaller.Password = null; // 设定服务名称 this.sInstaller.ServiceName = "FileMonitorService"; // 设定服务的启动方式 this.sInstaller.StartType = System.ServiceProcess.ServiceStartMode.Automatic; this.Installers.AddRange( new System.Configuration.Install.Installer[] {this.spInstaller, this.sInstaller }); } #endregion }
注意:类头前面的[RunInstaller(true)]必须得写,这是正确执行安装的前提.
打开.Net的SDK命令提示,输入installutil FileMonitorService.exe,这里的FileMonitorService.exe是相对路径名.输入命令之后就可以安装完成
在注册表中找到:HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services
新建一个文件夹,在这个文件夹建立几个项目:
1.Description这是windows服务的描述
2.DisplayName这是windows服务的显示名
3.ErrorControl是否提供错误控制
4.ImagePath这是windows服务的绝对路径
5.Start这是windows服务的启动类型
6.Type这是windows服务的类型
7.ObjectName是windows服务的帐户类型.
注意:文件夹的名称就是windows服务真实名称.
然后,重启一下机子就安装成功.