如何使用C#检测IIS版本?
更新:
我的意思是来自 winapp(实际上该场景是开发一个自定义安装程序,想要检查已安装 IIS 的版本以调用适当的 api)
在这里找到了答案:链接文本 http://forums.iis.net/p/1162404/1923867.aspx#1923867fileVersion 方法在 Windows 2008 上不起作用,我猜 inetserv exe 在其他地方。
public Version GetIisVersion()
{
using (RegistryKey componentsKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\InetStp", false))
{
if (componentsKey != null)
{
int majorVersion = (int)componentsKey.GetValue("MajorVersion", -1);
int minorVersion = (int)componentsKey.GetValue("MinorVersion", -1);
if (majorVersion != -1 && minorVersion != -1)
{
return new Version(majorVersion, minorVersion);
}
}
return new Version(0, 0);
}
}
我测试过,它在 Windows XP、7 和 2008 上完美运行
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)