다음을 통해 공유


IVCCollection 인터페이스

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

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

구문

‘선언
<GuidAttribute("F34846C1-D08D-4359-907E-0EE22987618B")> _
Public Interface IVCCollection _
    Inherits IEnumerable
[GuidAttribute("F34846C1-D08D-4359-907E-0EE22987618B")]
public interface IVCCollection : IEnumerable
[GuidAttribute(L"F34846C1-D08D-4359-907E-0EE22987618B")]
public interface class IVCCollection : IEnumerable
[<GuidAttribute("F34846C1-D08D-4359-907E-0EE22987618B")>]
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++ 확장성 개체 모델