VCFileCodeModel.AddInclude 方法

将 #include 元素添加到 VCFileCodeModel 对象中。

命名空间:  Microsoft.VisualStudio.VCCodeModel
程序集:  Microsoft.VisualStudio.VCCodeModel(在 Microsoft.VisualStudio.VCCodeModel.dll 中)

语法

声明
Function AddInclude ( _
    Name As String, _
    Position As Object _
) As VCCodeInclude
VCCodeInclude AddInclude(
    string Name,
    Object Position
)
VCCodeInclude^ AddInclude(
    String^ Name, 
    Object^ Position
)
abstract AddInclude : 
        Name:string * 
        Position:Object -> VCCodeInclude
function AddInclude(
    Name : String, 
    Position : Object
) : VCCodeInclude

参数

  • Name
    类型:String

    必选。 指定要包括的文件的名称(放在引号或尖括号中)。

  • Position
    类型:Object

    必选。 默认值 = 0。 将在其后添加新元素的代码元素。 如果该值为 CodeElement,则紧跟在其后添加新元素。

    因为集合从 1 开始计数,所以传递 0 表示应将新元素放置在集合的开始处。 值为 -1 表示应将元素放在结尾处。

返回值

类型:Microsoft.VisualStudio.VCCodeModel.VCCodeInclude
一个 VCCodeInclude 对象。

备注

调用此函数 #include 指令 (C/C++) 元素插入到 VCFileCodeModel 对象表示的文件。

有关如何编译和运行此示例的信息,请参见 如何:编译 Visual C++ 代码模型扩展性的示例代码

示例

此示例添加一个 #include 语句到 vcFile 对象表示的文件。

Sub AddInclude()
    Dim vcFile as VCFileCodeModel
    vcFile = DTE.Solution.Item(1).ProjectItems.Item(1).FileCodeModel
    vcFile.AddInclude("""stdafx.h""", 0)
End Sub

.NET Framework 安全性

请参阅

参考

VCFileCodeModel 接口

Microsoft.VisualStudio.VCCodeModel 命名空间