VS2008 下开发Windows Service(框架)

http://blog.csdn.net/kerneliahou/archive/2008/02/29/2133087.aspx

 

 

1 创建新工程

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章