C#实现Windows 服务的制作安装和删除

今天为大家整理一篇关于C#实现windows服务的制作与安装还有删除的文章,希望能帮助学习C#的同学进一步提高学习水平。

  运行Visual Studio.NET,建立一个C#的Windows服务项目。

  主程序代码:

以下为引用的内容:
以下是引用片段:
  using System;
  using System.Collections;
  using System.ComponentModel;
  using System.Data;
  using System.Diagnostics;
  using System.ServiceProcess;
  using System.Threading;
  using System.Windows.Forms;
  namespace CareEye
  ...{
  public class CareEye : System.ServiceProcess.ServiceBase
  ...{
  private Thread MainThread;
  /** 
  /// 必需的设计器变量。
  /// 
  private System.ComponentModel.Container components = null;
  public CareEye()
  ...{
  // 该调用是 Windows.Forms 组件设计器所必需的。
  InitializeComponent();
  // TODO: 在 InitComponent 调用后添加任何初始化
  MainThread = new Thread(new ThreadStart(ThreadFunc));
  MainThread.Priority = ThreadPriority.Lowest;
  }
  // 进程的主入口点
  static void Main()
  ...{
  //System.ServiceProcess.ServiceBase[] ServicesToRun;
  // 同一进程中可以运行多个用户服务。若要将
  //另一个服务添加到此进程,请更改下行
  // 以创建另一个服务对象。例如,
  //
  // ServicesToRun = New System.ServiceProcess.ServiceBase[] {new CareEye(), new MySecondUserService()};
  //
  //ServicesToRun = new System.ServiceProcess.ServiceBase[] { new CareEye() };
  System.ServiceProcess.ServiceBase.Run(new CareEye());
  }
  /** 
  /// 设计器支持所需的方法 - 不要使用代码编辑器
  /// 修改此方法的内容。
  /// 
  private void InitializeComponent()
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值