本文整理匯總了C#中System.ServiceProcess.ServiceProcessInstaller類的典型用法代碼示例。如果您正苦於以下問題:C# ServiceProcessInstaller類的具體用法?C# ServiceProcessInstaller怎麽用?C# ServiceProcessInstaller使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ServiceProcessInstaller類屬於System.ServiceProcess命名空間,在下文中一共展示了ServiceProcessInstaller類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: MyProjectInstaller
//引入命名空間
using System;
using System.Collections;
using System.Configuration.Install;
using System.ServiceProcess;
using System.ComponentModel;
[RunInstaller(true)]
public class MyProjectInstaller : Installer
{
private ServiceInstaller serviceInstaller1;
private ServiceInstaller serviceInstaller2;
private ServiceProcessInstaller processInstaller;
public MyProjectInstaller()
{
// Instantiate installers for process and services.
processInstaller = new ServiceProcessInstaller();
serviceInstaller1 = new ServiceInstaller();
serviceInstaller2 = new ServiceInstaller();
// The services run under the system account.
processInstaller.Account = ServiceAccount.LocalSystem;
// The services are started manually.
serviceInstaller1.StartType = ServiceStartMode.Manual;
serviceInstaller2.StartType = ServiceStartMode.Manual;
// ServiceName must equal those on ServiceBase derived classes.
serviceInstaller1.ServiceName = "Hello-World Service 1";
serviceInstaller2.ServiceName = "Hello-World Service 2";
// Add installers to collection. Order is not important.
Installers.Add(serviceInstaller1);
Installers.Add(serviceInstaller2);
Installers.Add(processInstaller);
}
public static void Main()
{
Console.WriteLine("Usage: InstallUtil.exe [<service>.exe]");
}
}