IVCCollection 인터페이스

IVCCollection 개체는 컬렉션 개체에 대해 수행할 수 있는 기능을 포함하고 있습니다.

네임스페이스:  Microsoft.VisualStudio.VCProjectEngine
어셈블리:  Microsoft.VisualStudio.VCProjectEngine(Microsoft.VisualStudio.VCProjectEngine.dll)

구문

‘선언
<GuidAttribute("BA03D89E-872B-4E4F-A186-61BA51119AC0")> _
Public Interface IVCCollection _
    Inherits IEnumerable
[GuidAttribute("BA03D89E-872B-4E4F-A186-61BA51119AC0")]
public interface IVCCollection : IEnumerable
[GuidAttribute(L"BA03D89E-872B-4E4F-A186-61BA51119AC0")]
public interface class IVCCollection : IEnumerable
[<GuidAttribute("BA03D89E-872B-4E4F-A186-61BA51119AC0")>]
type IVCCollection =  
    interface 
        interface IEnumerable 
    end
public interface IVCCollection extends IEnumerable

IVCCollection 형식에서는 다음과 같은 멤버를 노출합니다.

속성

  이름 설명
Public 속성 Count 컬렉션에 있는 개체의 수를 나타내는 값을 가져옵니다.
Public 속성 VCProjectEngine 프로젝트 엔진에 대한 개체 포인터를 가져옵니다.

위쪽

메서드

  이름 설명
Public 메서드 GetEnumerator 컬렉션의 항목에 대한 열거자를 반환합니다.
Public 메서드 Item 컬렉션에서 항목을 선택합니다.

위쪽

설명

예를 들어,의 Files 속성을 VCFilter 개체 폴더에 있는 파일의 컬렉션입니다.

예제

다음 예제에서는 사용 하는 방법은 EnablePREfastAdditionalOptions 속성을 설정 하는 /analyze:WX- 전환. (속성이 모두이 필요 합니다.) 지정 /analyze:WX- 사용 하 여 컴파일할 때 코드 분석 경고는 오류로 처리 되지 것입니다 /WX. 자세한 내용은 /analyze(코드 분석)를 참조하십시오.

이 예제를 실행 하 고 입력에 설명 된 대로이 예제를 실행 하려면 방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행. 다음의 새 인스턴스에서 Visual Studio, 로드는 Visual C++ 프로젝트 및 추가 기능 관리자를 사용 하 여 추가 기능을 활성화 합니다.

' Add reference to Microsoft.VisualStudio.VCProjectEngine.
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics
Imports Microsoft.VisualStudio.VCProjectEngine
Imports System.Text

Sub EnablePREfastExample(ByVal dte As DTE2)
    Dim prj As VCProject
    Dim cfgs, tools As IVCCollection
    Dim cfg As VCConfiguration
    Dim tool As VCCLCompilerTool
    Dim sb As New StringBuilder

    prj = CType(dte.Solution.Projects.Item(1).Object, _
      Microsoft.VisualStudio.VCProjectEngine.VCProject)
    cfgs = CType(prj.Configurations, _
      Microsoft.VisualStudio.VCProjectEngine.IVCCollection)
    cfg = CType(cfgs.Item(1), _
      Microsoft.VisualStudio.VCProjectEngine.VCConfiguration)
    tool = CType(cfg.Tools("VCCLCompilerTool"), _
      Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool)

    sb.Length = 0
    sb.Append("Current project PREfast setting: " _
      & tool.EnablePREfast & Environment.NewLine)
    sb.Append("Flag: " & tool.AdditionalOptions)
    MsgBox(sb.ToString)

    ' Toggle PREfast setting.
    If Not (tool.EnablePREfast = True) Then
        ' PREfast is not enabled. Turn it and the WX- flag on.
        tool.EnablePREfast = True
        tool.AdditionalOptions = "/analyze:WX-"
    Else
        ' Toggle the opposite.
        tool.EnablePREfast = False
        tool.AdditionalOptions = "/analyze:WX"
    End If
    sb.Length = 0
    sb.Append("New project PREfast setting: " _
      & tool.EnablePREfast & Environment.NewLine)
    sb.Append("Flag: " & tool.AdditionalOptions)
    MsgBox(sb.ToString)
End Sub
// Add references to Microsoft.VisualStudio.VCProjectEngine and 
// System.Windows.Forms.
using System;
using Extensibility;
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.VCProjectEngine;
using System.Text;
using System.Windows.Forms;

public void EnablePREfastExample(DTE2 dte)
{
    try
    {
        VCProject prj;
        IVCCollection cfgs, tools;
        VCConfiguration cfg;
        VCCLCompilerTool tool;
        StringBuilder sb = new StringBuilder();

        prj = (Microsoft.VisualStudio.VCProjectEngine.VCProject)
          dte.Solution.Projects.Item(1).Object;
        cfgs = 
          (Microsoft.VisualStudio.VCProjectEngine.IVCCollection)
          prj.Configurations;
        cfg = 
          (Microsoft.VisualStudio.VCProjectEngine.VCConfiguration)
           cfgs.Item(1);
        tools = 
          (Microsoft.VisualStudio.VCProjectEngine.IVCCollection)
          cfg.Tools;
        tool = 
          (Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool)
          tools.Item("VCCLCompilerTool");
                                
        sb.Length = 0;
        sb.Append("Current project PREfast setting: " +
          tool.EnablePREfast + Environment.NewLine);
        sb.Append("Flag: " + tool.AdditionalOptions);
        MessageBox.Show(sb.ToString());

        // Toggle PREfast setting.
        if (!(tool.EnablePREfast == true))
        {
            // PREfast is not enabled. Turn it and the WX- flag on.
            tool.EnablePREfast = true;
            tool.AdditionalOptions = "/analyze:WX-";
        }
        else
        {
            // Toggle the opposite.
            tool.EnablePREfast = false;
            tool.AdditionalOptions = "/analyze:WX";
        }
        sb.Length = 0;
        sb.Append("New project PREfast setting: " +
          tool.EnablePREfast + Environment.NewLine);
        sb.Append("Flag: " + tool.AdditionalOptions);
        MessageBox.Show(sb.ToString());
    }
    catch (System.Exception errmsg)
    {
        MessageBox.Show("ERROR! " + errmsg.Message);
    }
}

참고 항목

참조

Microsoft.VisualStudio.VCProjectEngine 네임스페이스

기타 리소스

프로젝트 모델에서 반환되는 HRESULT

Visual C++ 확장성 개체 모델