由网友(◇彺事щο都感謝×)分享简介:是否有可能如何在流程列举的AppDomain?Is there any possibility how to enumerate AppDomains within Process?推荐答案您可能想看看的这个帖子 using System.Runtime.InteropServices;// Add the...
是否有可能如何在流程列举的AppDomain?
Is there any possibility how to enumerate AppDomains within Process?
推荐答案
您可能想看看的这个帖子
using System.Runtime.InteropServices;
// Add the following as a COM reference - C:WINDOWSMicrosoft.NETFrameworkvXXXXXXmscoree.tlb
using mscoree;
public static IList<AppDomain> GetAppDomains()
{
IList<AppDomain> _IList = new List<AppDomain>();
IntPtr enumHandle = IntPtr.Zero
CorRuntimeHostClass host = new mscoree.CorRuntimeHostClass();
try
{
host.EnumDomains(out enumHandle);
object domain = null;
while (true)
{
host.NextDomain(enumHandle, out domain);
if (domain == null) break;
AppDomain appDomain = (AppDomain)domain;
_IList.Add(appDomain);
}
return _IList;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return null;
}
finally
{
host.CloseEnum(enumHandle);
Marshal.ReleaseComObject(host);
}
}
}
相关推荐
最新文章