赞
踩
做项目时用到判断iis是否安装的问题。查找了相应的资料,并整理实测了一下。亲测可用。
首先项目引用 System.ServiceProcess
protected void Page_Load(object sender, EventArgs e) { if (ExistSqlServerService("W3SVC")) { Response.Write("IIS已经存在了"); } else { Response.Write("IIS没有安装"); } } public static bool ExistSqlServerService(string tem) { bool ExistFlag = false; ServiceController[] service = ServiceController.GetServices(); for (int i = 0; i < service.Length; i++) { if (service[i].ServiceName.ToString() == tem) { ExistFlag = true; } } return ExistFlag; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。