Adding Command-line Switches
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Adding Command-line Switches

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Visual Studio SDK implementers might add command-line switches that apply to their VSPackages when devenv.exe is executed. The switches and their associated data must be added to the registry under the following key: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\AppCommandLine\<MySwitch>\].

The MySwitch key can take four values as shown in the following table.

Name Type Range Description



>= 0 and *

Number of arguments that follow the switch.



0x00000000 or 0x00000001

Load VSPackage if switch is present.



Not applicable

String to display with devenv /?.



Not applicable

GUID of VSPackage.

The first value of Arguments is usually 0 or 1. A special value of '*' can be used to indicate that the entire remainder of the command line is the argument. This can be useful for debugging scenarios where a user must pass in a debugger command string.

The DemandLoad value specifies a true (1) or false (0) indication that the integrated development environment (IDE) should force load your package. This is another of the IDE's delayed loading schemes.

The HelpString value is the string that appears in the devenv /? Help display. Keep this descriptive string short to maintain compatibility with other Help display strings.

The Package value is the GUID of the package that implements this switch. The IDE uses this GUID to find the VSPackage in the registry to which the command-line switch applies.

Retrieving Command-Line Switches

When your package is loaded, you can retrieve the command-line switches by completing the following steps.

  1. In your VSPackage's SetSite implementation, call QueryService on SVsAppCommandLine to get the IVsAppCommandLine interface.

  2. Call GetOption to retrieve the command-line switches that the user entered.

It is your responsibility to check for your command-line switches each time your package is loaded.

See Also

© 2015 Microsoft