VS2008 下开发Windows Service(框架)
http://blog.iyunv.com/kerneliahou/archive/2008/02/29/2133087.aspx1 创建新工程
file-->new-->project,选择Visual C#-->Windows-->Windows Service
在service的OnStart()和OnStop()里写上代码。
2 添加installer(必须,否则installutil无效,虽然指示安装成功)
在service 的设计视图中右键,选择Add Installer,添加installer,VS自动添加ProjectInstaller.cs,并在其中添加serviceInstaller1和serviceProcessInstaller1组件。在ProjectInstaller的设计视图中选择 serviceProcessInstaller1,修改他的Account属性为LocalSystem;同样修改serviceInstaller1的StartType属性,设置服务启动方式(手工、自动等)。
3 build你的project,生成service的exe文件
4 安装
installutil service-exe-path
5 卸载
installutil /u service-exe-path
页:
[1]