/** <summary> /// 服务器IIS版本 /// </summary> [Serializable] public enum WebServerTypes { /** <summary> /// 未知版本 /// </summary> Unknown, /** <summary> /// IIS 4.0 /// </summary> IIS4, /** <summary> /// IIS 5.0,5.1 /// </summary> IIS5, /** <summary> /// IIS 6.0 /// </summary> IIS6, /** <summary> /// IIS 7.0 /// </summary> IIS7 } public class IISHelper ...{ /** <summary> /// 获取服务器IIS版本 /// </summary> /// <param name="DomainName"></param> /// <returns></returns> public WebServerTypes GetIISServerType(string DomainName) ...{ DomainName = "LOCALHOST"; string path = "IIS://" + DomainName + "/W3SVC/INFO"; DirectoryEntry entry = null; try ...{ entry = new DirectoryEntry(path); } catch ...{ return WebServerTypes.Unknown; } int num = 5; try ...{ num = (int)entry.Properties["MajorIISVersionNumber"].Value; } catch { return WebServerTypes.IIS5; } switch (num) ...{ case 6: return WebServerTypes.IIS6; case 7: return WebServerTypes.IIS7; } return WebServerTypes.IIS6; } }
使用ADSI获取IIS版本
最新推荐文章于 2022-11-18 15:46:46 发布