1.在服务程序安装时编程实现,ProjectInstaller.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
//using System.Linq;
using Microsoft.Win32; //对注册表操作一定要引用这个命名空间
namespace MonitorService
{
[RunInstaller(true)]
public partial class ProjectInstaller : Installer
{
public ProjectInstaller()
{
InitializeComponent();
//this.Context.Parameters["ServerCode"].ToString(); // 读取安装时输入的服务器编号
}
private void ProjectInstaller_AfterInstall(object sender, InstallEventArgs e)
{
//设置允许服务与桌面交互
SetServiceTable("MonitorService");
}
/// <summary>
/// 设置允许服务与桌面交互 ,修改了注册表,要重启系统才能生效
/// </summary>
/// <param