What would the preferred way of programmatically determining which the currently installed version of Microsoft Internet Information Services (IIS) is?
I know that i
To identify the version from outside the IIS process, one possibility is like below...
string w3wpPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.System),
@"inetsrv\w3wp.exe");
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(w3wpPath);
Console.WriteLine(versionInfo.FileMajorPart);
To identify it from within the worker process at runtime...
using (Process process = Process.GetCurrentProcess())
{
using (ProcessModule mainModule = process.MainModule)
{
// main module would be w3wp
int version = mainModule.FileVersionInfo.FileMajorPart
}
}