只是想跟上SDK的进度...
所以,我已经创建了我自己的工具窗口...
现在,我希望遍历当前加载的解决方案中的现有项目,并在工具窗口中显示它们的名称...
但是不太确定枚举项目的最好方法是什么?有什么线索吗?
发布于 2008-11-20 05:08:16
static public IEnumerable<IVsProject> LoadedProjects
{
get
{
var solution = _serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
if (solution == null)
{
Debug.Fail("Failed to get SVsSolution service.");
yield break;
}
IEnumHierarchies enumerator = null;
Guid guid = Guid.Empty;
solution.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref guid, out enumerator);
IVsHierarchy[] hierarchy = new IVsHierarchy[1] { null };
uint fetched = 0;
for (enumerator.Reset(); enumerator.Next(1, hierarchy, out fetched) == VSConstants.S_OK && fetched == 1; /*nothing*/)
{
yield return (IVsProject)hierarchy[0];
}
}
}https://stackoverflow.com/questions/304361
复制相似问题