VCCodeModel.AddIDLLibrary 方法

将新的 library 语句添加到特定 .idl 文件。

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

语法

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

参数

  • Name
    类型:String

    必需。 指定新库的名称。

  • Location
    类型:Object

    必需。 要修改的 .idl 文件的路径或文件名。 如果文件不存在,则自动创建该文件。 如果该文件还不是项目项,则将该文件添加到项目中。 如果无法创建该文件并将其添加到项目中,则 AddIDLLibrary 失败。

  • Position
    类型:Object

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

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

返回值

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

备注

称此功能插入 library 语句添加到 VCCodeModel 对象的指定 .idl 文件中。

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

示例

此示例添加一个库语句添加到 Project.idl 文件的结尾。

Sub AddIDLLibrary()
    Dim codeModel As VCCodeModel
    codeModel = DTE.Solution.Item(1).CodeModel
    Dim idlLibrary As VCCodeIDLLibrary
    idlLibrary = codeModel.AddIDLLibrary("MyLibrary", "Project.idl", -1)
End Sub

.NET Framework 安全性

请参阅

参考

VCCodeModel 接口

Microsoft.VisualStudio.VCCodeModel 命名空间