-----------立即啟動--------------
private void serviceInstaller1_AfterInstall(object sender, System.Configuration.Install.InstallEventArgs e)
{
ServiceController myService = new ServiceController( "XJOAPigeonholeServer ");
myService.Start();
myService.Dispose();
}
添加描述:1.1沒有直接方法,2.0裡有直接的方法 ServiceInstaller.Description
//----------------------------添加服務描述信息 開始 ------------
public override void Install(IDictionary stateServer)
{
Microsoft.Win32.RegistryKey system,
//HKEY_LOCAL_MacHINE\Services\CurrentControlSet
currentControlSet,
//...\Services
services,
//...\ <Service Name>
service,
//...\Parameters - this is where you can put service-specific configuration
config;
try
{
//Let the project installer do its job
base.Install(stateServer);
//Open the HKEY_LOCAL_MacHINE\SYSTEM key
system = Microsoft.Win32.Registry.LocalMachine.OpenSubKey( "System ");
//Open CurrentControlSet
currentControlSet = system.OpenSubKey( "CurrentControlSet ");
//Go to the services key
services = currentControlSet.OpenSubKey( "Services ");
//Open the key for your service, and allow writing
service = services.OpenSubKey(this.serviceInstaller1.ServiceName, true);
//Add your service ''s description as a REG_SZ value named "Description "
service.SetValue( "Description ", "XJOA系統自動歸檔服務(BeijiOffice) ");
//(Optional) Add some custom information your service will use...
//允許服務與桌面交互
service.SetValue( "Type ",0x00000110);
config = service.CreateSub