Last active
August 29, 2015 14:25
-
-
Save mishrsud/64c8bf372c901860cc83 to your computer and use it in GitHub Desktop.
Reads IIS Version of the registry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Gets the IIS version from registry. | |
/// </summary> | |
/// <remarks> | |
/// From SO: http://stackoverflow.com/a/1699947/190476 | |
/// </remarks> | |
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment