http://www.codeproject.com/KB/cs/Start_Stop_IIS_Website.aspx
or (from http://kadnan.com/blog/2005/02/15/diplay-iis-hosted-site-names-in-c/) :
try
{
const string WebServerSchema = “IIsWebServer”; // Case
Sensitive
string ServerName = “SIDDIQI”;
DirectoryEntry W3SVC = new
DirectoryEntry(”IIS://” + ServerName + “/w3svc”, “Domain/UserCode”,
“Password”);
foreach (DirectoryEntry Site in W3SVC.Children)
{
if (Site.SchemaClassName ==
WebServerSchema)
{
//Console.WriteLine(Site.Name + ” - ” +
Site.Properties[”ServerComment”].Value.ToString());
}
}
}
// Catch
any errors
catch (Exception e)
{
Console.WriteLine(”Error: ” +
e.ToString());
}