您的位置:首页 > 编程语言 > C#

C#windows service效劳装置、注册、判别效劳能否存在、能否发动

2013-03-13 00:00 281 查看
#region Windows效劳控制区

#region 装置效劳
private void InstallService(IDictionary stateSaver, string filepath)
{
try
{
ServiceController http://www.kp1111.info/linked/20130312.do  service = new ServiceController("ServiceName");
if (!ServiceIsExisted("ServiceName"))
{
//Install Service
AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();
myAssemblyInstaller.UseNewContext = true;
myAssemblyInstaller.Path = filepath;
myAssemblyInstaller.Install(stateSaver);
myAssemblyInstaller.Commit(stateSaver);
myAssemblyInstaller.Dispose();
//--Start Service
service.Start();
}
else
{
if (service.Status != System.ServiceProcess.ServiceControllerStatus.Running  http://www.aaafaipiao.com/linked/20130312.do[/code] 
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: