DTE2.LaunchWizard 方法

用提供的参数运行向导。

命名空间:  EnvDTE80
程序集:  EnvDTE80(在 EnvDTE80.dll 中)

语法

声明
Function LaunchWizard ( _
    VSZFile As String, _
    ByRef ContextParams As Object() _
) As wizardResult
wizardResult LaunchWizard(
    string VSZFile,
    ref Object[] ContextParams
)
wizardResult LaunchWizard(
    [InAttribute] String^ VSZFile, 
    [InAttribute] array<Object^>^% ContextParams
)
abstract LaunchWizard : 
        VSZFile:string * 
        ContextParams:Object[] byref -> wizardResult
function LaunchWizard(
    VSZFile : String, 
    ContextParams : Object[]
) : wizardResult

参数

  • VSZFile
    类型:String

    必选。 .Vsz(向导)文件包含启动向导所需的信息。

  • ContextParams
    类型:array<Object[]%

    必选。 向导的参数。 第一个参数是唯一标识启动上下文,以使其不同于 Add Item 或 Add Project 的 GUID 或自定义的 GUID。 其余的参数是用户定义的,它们的数目和值取决于向导。

    Visual Studio 附带的向导或模板(如 Visual Basic Windows 应用程序或 Visual C# 控制台应用程序)具有一组必须传递给它们的必需的上下文参数。 这些详细信息,请参见 ContextParams 枚举。 您创建的向导有或多或少都需要参数。

返回值

类型:wizardResult
一个 wizardResult 对象。

备注

IDE 的主用户界面 (UI) 线程与向导的执行同步,因此用户在向导完成前无法执行任何操作。

下面的宏示例说明如何使用 LaunchWizard 方法启动 Visual Studio“添加项”向导。 该向导使用 7 个自定义参数,以便设置每个参数的值。 任何异常由 Try...Catch 块捕获。

示例

Sub LaunchWizardExample()
   Dim params() As Object = New Object() { _
     "{0F90E1D0-4999-11D1-B6D1-00A0C90F2744}", _  ' Param 0
     "MyConsoleProject", _                        ' Param 1
     "C:\MyProjects", _                           ' Param 2
     "", _                                        ' Param 3
     False, _                                     ' Param 4
     "", _                                        ' Param 5
     False}                                       ' Param 6
   ' The wizardResult constant determines the state of the wizard, such 
   ' as whether it completed, was canceled, and so on.
   Dim res As EnvDTE.wizardResult
   ' Set the project type to a Visual Basic project.
   Dim str As String = _
     DTE.Solution.TemplatePath(VSLangProj.PrjKind.prjKindVBProject)

   ' Start the Visual Basic Console Application wizard by using the
   ' supplied parameters. Exceptions are caught below.
   Try
      res = DTE2.LaunchWizard(str & "ConsoleApplication.vsz", params)
   Catch e1 As System.Exception
      MsgBox("Error: " & e1.Message)
   End Try
End Sub

.NET Framework 安全性

请参阅

参考

DTE2 接口

EnvDTE80 命名空间