Just trying to get up to speed with the SDK...
So, I've created my own tool window....
Now I want to iterate through the existing projects in the currently loaded solution and display their names in the tool window....
but not quite sure what the best way to enumerate the projects? any clues?
Check this code by Microsoft:
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];
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With