共用方式為


VCProject.AddActiveXReference 方法

將 ActiveX (COM) 參考加入至專案。

命名空間:  Microsoft.VisualStudio.VCProjectEngine
組件:  Microsoft.VisualStudio.VCProjectEngine (在 Microsoft.VisualStudio.VCProjectEngine.dll 中)

語法

'宣告
Function AddActiveXReference ( _
    typeLibGuid As String, _
    majorVersion As Integer, _
    minorVersion As Integer, _
    localeID As Integer, _
    wrapper As String _
) As Object
Object AddActiveXReference(
    string typeLibGuid,
    int majorVersion,
    int minorVersion,
    int localeID,
    string wrapper
)
Object^ AddActiveXReference(
    [InAttribute] String^ typeLibGuid, 
    [InAttribute] int majorVersion, 
    [InAttribute] int minorVersion, 
    [InAttribute] int localeID, 
    [InAttribute] String^ wrapper
)
abstract AddActiveXReference : 
        typeLibGuid:string * 
        majorVersion:int * 
        minorVersion:int * 
        localeID:int * 
        wrapper:string -> Object 
function AddActiveXReference(
    typeLibGuid : String, 
    majorVersion : int, 
    minorVersion : int, 
    localeID : int, 
    wrapper : String
) : Object

參數

  • typeLibGuid
    型別:System.String
    表示型別程式庫 GUID 的字串。
  • majorVersion
    型別:System.Int32
    表示主要版本號碼的整數。
  • minorVersion
    型別:System.Int32
    表示次要版本號碼的整數。
  • localeID
    型別:System.Int32
    表示地區設定 ID 的整數。
  • wrapper
    型別:System.String
    表示包裝函式名稱的字串。可以是空白。

傳回值

型別:System.Object
表示專案參考的物件。

備註

取得這個方法的參數的方法之一,就是新增至您的專案所需的參考、 儲存的專案,然後檢查它的.vcxproj 檔案。 參數都會在"ActiveXReference"。

範例

請參閱HOW TO:編譯專案模型擴充性的範例程式碼如需有關如何編譯及執行這個範例資訊。

AddActiveXReference將 ActiveX 型別程式庫參考加入至專案根據您所提供的使用的參數,若有的話。

Imports EnvDTE
Imports System.Diagnostics
Imports Microsoft.VisualStudio.VCProjectEngine

Public Module Module1
    Sub Test()
        Dim prj As VCProject
        Dim tlguid, wrapper As String
        Dim majver, minver, lcid As Integer

        ' Add the following values:
        ' tlguid = The guid for the EnvDTE COM type library.
        ' wrapper = The wrapper name for EnvDTE, taken from .vcxproj file.
        ' majver, minver = The major and minor versions of DTE, 
        '                  taken from the .vcxproj file.
        ' lcid = The localization ID. 1033 is English. 
        '        Each language has its own LCID.
        tlguid = "{80CC9F66-E7D8-4DDD-85B6-D9E6CD0E93E2}"
        wrapper = "primary"
        majver = 7
        minver = 0
        lcid = 1033
        prj = DTE.Solution.Projects.Item(1).Object
        If prj.CanAddActiveXReference(tlguid, majver, minver, lcid, _
          wrapper) Then
            prj.AddActiveXReference(tlguid, majver, minver, lcid, wrapper)
        Else
            MsgBox("Cannot add the specified ActiveX typelib reference.")
        End If
    End Sub
End Module

.NET Framework 安全性

請參閱

參考

VCProject 介面

Microsoft.VisualStudio.VCProjectEngine 命名空間