C# VS2010服务(service)
来源:互联网 发布:js {} 冒号与= 编辑:程序博客网 时间:2024/06/11 06:18
一:使用ServiceController控制windows服务
C#中,使用ServiceController类控制windows服务,
使用之前要先添加引用:System.ServiceProcess,
然后在命名空间中引用:using System.ServiceProcess
创建 ServiceController 的实例后,必须为其设置两个属性来标识与其交互的服务:计算机名称和要控制的服务的名称,
MachineName 默认设置为本地计算机,除非想将该实例设置为指向另一台计算机不,否则不要修改。
方法:ServiceController.GetServices()返回非设备驱动程序服务和不是驱动程序的服务。若要检索设备驱动程序服务,请调用 GetDevices 方法。这两种方法一起提供对计算机上所有服务的访问。
属性:Status表示现有服务的运行状态。取值包括:
ContinuePending 服务即将继续。
Paused 服务已暂停。
PausePending 服务即将暂停。
Running 服务正在运行。
StartPending 服务正在启动。
Stopped 服务未运行。
StopPending 服务正在停止。
安装服务:
方法一、使用DOS命令安装window服务
操作:用管理员权限打开Visual Studio 2010 Command Prompt(VS自带的命令行)->进入到编译生成可执行文件的目录安装:输入命令 InstallUtil 服务名称
卸载:输入命令 InstallUtil /u 服务名称
启动:输入命令 net start 服务名称 或者 sc start 服务名称
停止:输入命令 net stop 服务名称 或者 sc stop 服务名称
如何删除一个服务:
①sc delete ServiceName
②在注册表HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services下找到对应的服务,删除即可。
方法二、使用安装项目安装windows服务
http://blog.csdn.net/wangzhen209/article/details/52931463
方法三、
在ProjectInstaller.cs的后台代码中添加安装服务和卸载服务的代码
注:
如何创建 Windows 服务 https://msdn.microsoft.com/zh-cn/library/9k985bc9.aspx
调试 Windows 服务应用程序 https://msdn.microsoft.com/zh-cn/library/7a50syb3.aspx
- C# VS2010服务(service)
- Windows ATL Service 服务的创建(VS2010)
- VS2010 C# 调用Web Service
- 使用VS2010(C#语言)创建Windows Service详细图解
- VS2010 C# 创建Windows服务
- vs2010 编写windows service 服务程序
- VS2010 编写windows service 服务程序
- vs2010 编写windows service 服务程序
- C#制作Windows service服务
- C# 创建Windows Service服务 Windows服务
- 用C#开发Windows Service服务教程(多图)
- C# 编写Windows Service(windows服务程序)
- C# 编写Windows Service(windows服务程序)
- C# 编写Windows Service(windows服务程序)
- C# 编写Windows Service(windows服务程序)
- C# 编写Windows Service(windows服务程序)
- C# 编写Windows Service(windows服务程序)
- C# VS2010 windows服务的安装
- 富文本编辑器(ckEditor)集成struts2实现文件的上传
- stringstream 的使用注意事项
- 快速排序
- Android Support Annotation Library 使用
- Android中visible与invisible的区别
- C# VS2010服务(service)
- oracle 11g rac+ASM,alert日志报错oraORA-15025,ORA-27041Permission denied
- uitableview中设置某个cell不能选中,其他可以选
- spring mvc 表单控制器
- 搭建独立服务收获
- asp中input标签date属性默认值设定
- 《自己动手设计数据库》第8章 键
- 最小生成树PRIM算法
- 占位1