次の方法で共有


_DTE.LaunchWizard(String, Object[]) Method

Definition

Runs a wizard with the supplied parameters.

public:
 EnvDTE::wizardResult LaunchWizard(System::String ^ VSZFile, cli::array <System::Object ^> ^ % ContextParams);
EnvDTE::wizardResult LaunchWizard(std::wstring const & VSZFile, std::Array <winrt::Windows::Foundation::IInspectable const &> const & & ContextParams);
[System.Runtime.InteropServices.DispId(232)]
public EnvDTE.wizardResult LaunchWizard (string VSZFile, ref object[] ContextParams);
[<System.Runtime.InteropServices.DispId(232)>]
abstract member LaunchWizard : string * Object[] -> EnvDTE.wizardResult
Public Function LaunchWizard (VSZFile As String, ByRef ContextParams As Object()) As wizardResult

Parameters

VSZFile
String

Required. The .Vsz (wizard) file containing the information required to launch the wizard.

ContextParams
Object[]

Required. The parameters for the wizard. The first parameter is a GUID that uniquely identifies the launch context as distinct from Add Item or Add Project or a custom GUID. The remaining arguments are user-defined and their number and values depend on the wizard.

Wizards (or templates) that come with Visual Studio — such as Visual Basic Windows Application or Visual C# Console Application—have a required set of context parameters that you must pass to them. For details on these, see ContextParams Enum. Wizards that you create can have more or less parameters.

Returns

A wizardResult object.

Attributes

Examples

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 did it complete or was it canceled, etc.  
   Dim res As EnvDTE.wizardResult  
   ' Set the project type to a Visual Basic project.  
   Dim s As String = _  
     DTE.Solution.TemplatePath(VSLangProj.PrjKind.prjKindVBProject)  

   ' Launch the Visual Basic Console Application wizard using the  
   ' supplied parameters. Any exceptions are caught below.  
   Try  
      res = DTE.LaunchWizard(s & "ConsoleApplication.vsz", params)  
   Catch e1 As System.Exception  
      MsgBox("Error: " & e1.Message)  
   End Try  
End Sub  

Remarks

The main UI thread of the IDE is synchronous with the wizard's execution, so users cannot do anything until the wizard completes.

The following macro example demonstrates how to use the LaunchWizard method to launch the Visual Studio Add Item wizard. This wizard uses seven custom parameters, so values are set for each one. Any exceptions are caught by the Try...Catch block.

Applies to