Пример #1
0
static EnvDTE::ProjectItemPtr FindItem(EnvDTE::ProjectPtr pProject, _bstr_t ItemName, EnvDTE::ProjectItemPtr pPrevElem)
{
	EnvDTE::ProjectItemsPtr pItems = NULL;
	if (pPrevElem == NULL)
	{
		pProject->get_ProjectItems(&pItems);
	}
	else
	{
		pPrevElem->get_ProjectItems(&pItems);
	}
	if (pItems == NULL)
		return EnvDTE::ProjectItemPtr(NULL);
	long Count;
	pItems->get_Count(&Count);
	if (Count == 0)
		return EnvDTE::ProjectItemPtr(NULL);
	for (long i = 1; i <= Count; i++)
	{
		EnvDTE::ProjectItemPtr pItem;
		pItems->Item(_variant_t(i), &pItem);
		_bstr_t IName;
		pItem->get_Name(IName.GetAddress());

		if (!_wcsicmp(IName, ItemName))
		{
			return pItem;
		}

		EnvDTE::ProjectItemPtr pItem2 = FindItem(pProject, ItemName, pItem);
		if (pItem2 != NULL)
			return pItem2;
	}
	return EnvDTE::ProjectItemPtr(NULL);
}
Пример #2
0
static EnvDTE::ProjectItemPtr EnumItem(EnvDTE::ProjectPtr & pProject, CSimpleArray<CString> & ar, EnvDTE::ProjectItemPtr pPrevElem)
{
	EnvDTE::ProjectItemsPtr pItems = NULL;
	if (pPrevElem == NULL)
	{
		pProject->get_ProjectItems(&pItems);
	}
	else
	{
		pPrevElem->get_ProjectItems(&pItems);
	}
	if (pItems == NULL)
		return EnvDTE::ProjectItemPtr(NULL);
	long Count;
	pItems->get_Count(&Count);
	if (Count == 0)
		return EnvDTE::ProjectItemPtr(NULL);
	for (short i = 1; i <= Count; i++)
	{
		EnvDTE::ProjectItemPtr pItem;
		pItems->Item(_variant_t(i), &pItem);
		_bstr_t IName;
		//pItem->get_Name(IName.GetAddress());
		pItem->get_FileNames(i,IName.GetAddress());
		/*
		if (!_wcsicmp(IName, ItemName))
		{
			return pItem;
		}
		*/
		CString Name = (LPCTSTR)IName;
		ar.Add(Name);
		EnvDTE::ProjectItemPtr pItem2 = EnumItem(pProject, ar,pItem);
		if (pItem2 != NULL)
			return pItem2;
	}
	return EnvDTE::ProjectItemPtr(NULL);
}