代码如下:
using System.ComponentModel;
using System.Configuration.Install;
using System.ServiceProcess;
namespace WindowsService1
{
[RunInstaller(true)]
public partial class InstallerService : Installer
{
private ServiceProcessInstaller process;
private ServiceInstaller service;
public InstallerService()
{
process = new ServiceProcessInstaller();
process.Account = ServiceAccount.LocalSystem;
service = new ServiceInstaller();
service.ServiceName = "SimegyServiceTest";
Installers.Add(process);
Installers.Add(service);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
namespace WindowsService1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new Service1()
};
ServiceBase.Run(ServicesToRun);
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Security.Cryptography;
namespace WindowsService1
{
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
this.CanPauseAndContinue = true;
this.CanShutdown = true;
this.CanHandleSessionChangeEvent = false;
this.ServiceName = "SimegyService_Test";
}
protected override void OnStart(string[] args)
{
// System.Threading.Thread.Sleep(5 * 1000 * 60);
}
protected override void OnStop()
{
}
}
}
分享到:
相关推荐
利用C#开发的window服务DEMO,详细介绍具体开发
c# window服务多线程实例
C#创建简单window服务适用于初学服务者 说明:在项目bin\Debug目录下有三个文件: CreateMMISService.bat:创建服务命令 DeleteMMISService.bat:删除服务命令 TimeFile.txt:记录时间文件
window服务程序打包实例,服务启动某个应用程序。 打包将安装路径写入注册表,在服务启动时查询注册表信息启动应用程序.
vs2010创建c# windowService图文详细说明文档可以帮你解决以下问题: 如果创建c# windowService项目程序? 如何创建window服务的安装程序? 如何创建window文件监控程序? 如何启动window服务程序? window服务程序...
C#基本书写规范C#基本书写规范
C#基本书写规范,最新,C#基本书写规范,C#基本书写规范。C#基本书写规范。
C# 界面化 UI 实现window服务 的安装、启用、停用、卸载 window服务安装方式 比较鸡肋,网上也没有像样的界面化安装方式,自己实现了个 winForm 界面还是很美观的,工具很实用,特别是经常接触window服务的
C# 界面化 window服务管理 做的一个 winform 对window服务管理很有帮助
c#类似windowxp界面c#类似windowxp界面
自己根据网上的代码抄的哈
C# 开机启动服务(windows service) 本程序用ASP.NET C#开发,不针对系统版本限制。 本源码拿就来可以直接写您想要的服务,无需再改其它的代码,拿来主义是不是很好?例如订单服务。 本服务是100%源码,源码中包含: ...
《C#语言Window+s程序设计》源码,各个章节的代码,包含学生学籍管理系统及图书管理系统的源代码
利用C# 部署Windows 服务,自动控制相关内容。 常用于程序的自动审核。
可以方便的打印各种报表,单据,并且纯c#代码,使用时公需要引入一个dll文件,没有任何功能性限制,qq:19335579
C#书写规范
C#建立最简单的Web服务,无需IIS
利用Windows10系统API实现的C#通知,可以实现使用C#推送通知到Win10通知栏,并可以和该通知进行交互。
C# Window 服务 启动exe 兼容 win7