解决方案 »
- datagrid问题
- 【分享】纯手工打造Emit,实现AOP,附源码下载
- 居中的问题
- 正则获取html的结束标签之间的内容,详情见文章内容
- 每次当datagrid绑定完后,想再在datagrid动态增加几行,什么实现?
- ASP.NET 时间触发器
- 哪位大侠帮帮忙吧 急急急,在线等
- 在线等待:http://202.111.175.177/index.aspx打开说Web.Config文件中customErrors出错,可是我在网站上的根目录中的WebConfig文件不是这
- C# 如何作论坛,有没能好思路
- 30多岁的老男人,0基础学编程是否逆天
- 关于资金修改的一段代码
- ASP静态生成技术怎么生成的?求高手,求专业人士
另外读注册表中有信息吗?会不会涉及到WIN7/WIN2008的权限问题?
foreach (ApplicationPool pool in AppPools)
...{
Console.WriteLine(pool.Name);
}
/**//// <summary>
/// 获取应用程序池->数组
/// </summary>
/// <returns></returns>
public ApplicationPool[] GetApplicationPools()
...{
if ((SiteInfo.ServerType != WebServerTypes.IIS6) && (SiteInfo.ServerType != WebServerTypes.IIS7)) return null;
DirectoryEntry directoryEntry = GetDirectoryEntry("IIS://LOCALHOST/W3SVC/AppPools");
if (directoryEntry == null) return null;
List<ApplicationPool> list = new List<ApplicationPool>();
foreach (DirectoryEntry entry2 in directoryEntry.Children)
...{
PropertyCollection properties = entry2.Properties;
ApplicationPool pool = new ApplicationPool();
pool.Name = entry2.Name;
list.Add(pool);
}
return list.ToArray();
}
/**//// <summary>
/// 应用程序池
/// </summary>
public class ApplicationPool
...{ /**//// <summary>
/// 版本
/// </summary>
public string DotNetVersion = "v2.0.50727";
/**//// <summary>
/// 应用程序池名
/// </summary>
public string Name = "";
}
using System.DirectoryServices; string method="Start"; //Start开启 Recycle回收 Stop 停止
string AppPoolName = "chengxuchiname";
try
{
DirectoryEntry appPool = new DirectoryEntry("IIS://localhost/W3SVC/AppPools");
DirectoryEntry findPool = appPool.Children.Find(AppPoolName,"IIsApplicationPool");
findPool.Invoke(method,null);
appPool.CommitChanges();
appPool.Close();
MessageBox.Show("应用程序池名称启动成功","启动成功");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,"启动失败");
}//获取应用程序池列表 等操作
/// <summary>
/// 获取应用程序池->数组
/// </summary>
/// <returns></returns>
public ApplicationPool[] GetApplicationPools()
{
if ((SiteInfo.ServerType != WebServerTypes.IIS6) && (SiteInfo.ServerType != WebServerTypes.IIS7)) return null;
DirectoryEntry directoryEntry = GetDirectoryEntry("IIS://LOCALHOST/W3SVC/AppPools");
if (directoryEntry == null) return null;
List<ApplicationPool> list = new List<ApplicationPool>();
foreach (DirectoryEntry entry2 in directoryEntry.Children)
{
PropertyCollection properties = entry2.Properties;
ApplicationPool pool = new ApplicationPool();
pool.Name = entry2.Name;
list.Add(pool);
}
return list.ToArray();
}
/// <summary>
/// 应用程序池
/// </summary>
public class ApplicationPool
{ /// <summary>
/// 版本
/// </summary>
public string DotNetVersion = "v2.0.50727";
/// <summary>
/// 应用程序池名
/// </summary>
public string Name = "";
}连接
DirectoryEntry findPool = appPool.Children.Find("Prodika v6.1.1.0", "IIsApplicationPool"); string b = "";
foreach (string a in findPool.Properties.PropertyNames)
{
b += string.Format("{0}={1}\n", a, findPool.InvokeGet(a));
} return b;可以得到如下值,其中就有我要的:
AppPoolIdentityType=0
AppPoolState=2
Win32Error=0
AppPoolCommand=1
KeyType=IIsApplicationPool
AppPoolAutoStart=True
Enable32BitAppOnWin64=True //我就是要这个
ManagedPipelineMode=1★★注意,启动进程池的账号必须有‘管理员’权限,否则会报 access is denied.