首页| JavaScript| HTML/CSS| Matlab| PHP| Python| Java| C/C++/VC++| C#| ASP| 其他|
购买积分 购买会员 激活码充值

您现在的位置是:虫虫源码 > C# > C#启动Windows IIS服务的实例

C#启动Windows IIS服务的实例

  • 资源大小:37.23 kB
  • 上传时间:2021-06-29
  • 下载次数:0次
  • 浏览次数:0次
  • 资源积分:1积分
  • 标      签: 其他

资 源 简 介

C#启动指定的Windows信使服务,本例中是启动IIS服务,在Windows XP下可完美运行,在Windows7下不行好像,本程序演示如何在C#的程序中启动一个指定的Windows内置服务的方法。具体的实现代码:   ServiceController service = new ServiceController();//创建服务控制对象   service.ServiceName = "Messenger";//启动Windows信史服务   //判断当前服务状态   if (service.Status == ServiceControllerStatus.Stopped)   {    try    {    service.Start();// 启动服务    service.WaitForStatus(ServiceControllerStatus.Running);    }    catch (InvalidOperationException)    {    MessageBox.Show("不能启动该服务!");    }   }

文 件 列 表

srcfans.com
StartWindowsService
StartWindowsService
StartWindowsService
bin
Debug
StartWindowsService.exe
srcfans.com
VIP VIP
0.171334s