做windows服务程序的安装程序是不是可以选择启动类型吗?
选择自动的话开机就会执行丫!
选择自动的话开机就会执行丫!
解决方案 »
- 求帮忙把一个C#正则弄成一个js正则。
- ZedGraph问题续:两个ZedGraph控件之间的同步问题
- 关于 天敏vc8000视频采集卡 动态监测功能 问题
- 请问如何根据菜单的不同,在同一个页面default.aspx加载不同的ascx控件
- 几个低级但又棘手的问题
- .net中的子窗体和父窗体如何操作
- 菜鸟问题 : VS 中 main() 函数的执行!
- VS2012安装MVC在数据中找不到ADO.NET实体数据模型
- 如何中止一项正在进行的任务?
- 求助如何在datagrid中删除增加一条记录阿??
- 求救高手:关于正则表达式
- 如何实现用[]给类的示例输入参数,就像PropertyCollection那样
http://www.c-sharpcorner.com/2/window_service.asp还有更多,看看这里:
http://www.c-sharpcorner.com/WindowsServices.asp
using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration.Install; namespace CodeGuru.MyWindowsService
{
/// <summary>
/// Summary description for ProjectInstaller.
/// </summary>
[RunInstaller(true)]
public class ProjectInstaller :
System.Configuration.Install.Installer
{
private System.ServiceProcess.ServiceProcessInstaller
serviceProcessInstaller1;
private System.ServiceProcess.ServiceInstaller serviceInstaller1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null; public ProjectInstaller()
{
// This call is required by the Designer.
InitializeComponent(); // TODO: Add any initialization after the InitComponent call
} #region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.serviceProcessInstaller1 = new
System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new
System.ServiceProcess.ServiceInstaller();
//
// serviceProcessInstaller1
//
this.serviceProcessInstaller1.Account =
System.ServiceProcess.ServiceAccount.LocalSystem;
this.serviceProcessInstaller1.Password = null;
this.serviceProcessInstaller1.Username = null;
//
// serviceInstaller1
//
this.serviceInstaller1.ServiceName = "My Sample Service";
//
//下面设置服务开机自行启动;
//
this.serviceInstaller1.StartType =
System.ServiceProcess.ServiceStartMode.Automatic;
//
// ProjectInstaller
//
this.Installers.AddRange(new
System.Configuration.Install.Installer[]
{this.serviceProcessInstaller1, this.serviceInstaller1});
}
#endregion
}
}