Share via


ProjectItems 인터페이스

업데이트: 2007년 11월

각각 프로젝트의 항목을 나타내는 ProjectItem 개체를 포함합니다.

네임스페이스:  EnvDTE
어셈블리:  EnvDTE(EnvDTE.dll)

구문

<GuidAttribute("8E2F1269-185E-43C7-8899-950AD2769CCF")> _
Public Interface ProjectItems _
    Implements IEnumerable

Dim instance As ProjectItems
[GuidAttribute("8E2F1269-185E-43C7-8899-950AD2769CCF")]
public interface ProjectItems : IEnumerable
[GuidAttribute(L"8E2F1269-185E-43C7-8899-950AD2769CCF")]
public interface class ProjectItems : IEnumerable
public interface ProjectItems extends IEnumerable

설명

이 컬렉션은 각 프로젝트의 항목을 나타내는 계단식 ProjectItems 컬렉션의 계층(중첩) 구조로 구성됩니다.

Solution.Item().ProjectItems를 사용하여 이 컬렉션을 참조할 수 있습니다.

참고:

Visual Studio .NET 2003 및 Visual Studio 2005에서는 Visual C++의 Project.ProjectItems 컬렉션을 별도로 처리할 필요가 없습니다. 즉, 이전 버전에서는 Visual C++ ProjectItems 컬렉션에 모든 Visual C++ 프로젝트 파일이 기본 목록 형식으로 저장되었지만 이제는 다른 프로그래밍 언어와 마찬가지로 파일이 계층 구조로 저장됩니다.

이러한 변경은 기존 코드에 영향을 줄 수 있으므로 프로젝트에 파일이 있는지 여부를 확인하기 위해 Project.ProjectItems 컬렉션을 인덱싱할 경우 새 프로젝트별 개체 모델에서 이전 버전의 동작을 에뮬레이트해야 합니다. 새 버전에서는 Visual C++ 개체에서 .Object를 호출하여 DTE 개체로 돌아올 수 있다는 것이 주요 차이점입니다.

Dim proj as VCProject = DTE.ActiveSolutionProjects(0).Object
Dim fileColl as IVCCollection = proj.Files
Dim file as VCFile = fileColl.Item("MyFile.cpp")
Dim projItem as ProjectItem = file.Object

예제

' Before running, create a new project or open an existing project.
Sub ListProj()
   Dim proj As Project = DTE.ActiveSolutionProjects(0)
   Dim win As Window = _
     DTE.Windows.Item(Constants.vsWindowKindCommandWindow)
   ListProjAux(proj.ProjectItems(), 0)
End Sub

Sub ListProjAux(ByVal projitems As ProjectItems, ByVal Level As Integer)
   Dim projitem As ProjectItem
   For Each projitem In projitems
      MsgBox("Project item: " & projitem.Name, Level)
      ' Recurse if the project item has sub-items...
      Dim projitems2 As ProjectItemsprojitems2 = projitem.ProjectItems
      Dim notsubcoll As Boolean = projitems2 Is Nothing
      If Not notsubcoll Then
         ListProjAux(projitems2, Level + 1)
      End If
   Next
End Sub

참고 항목

참조

ProjectItems 멤버

EnvDTE 네임스페이스

기타 리소스

프로젝트 및 솔루션 제어

방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행