Registering the Add-in

 < Free Open Study > 

Once an add-in is created, it must be registered as a COM component with Microsoft Windows. As described earlier in this chapter, the Add-in Wizard automatically performs this registration for you. Obviously, I have used the wizard to create the add-in for me, and it has registered the add-in. If you choose to run the code for this chapter, or any chapter in this book, without using the Add-in Wizard, you will need to register the add-in.

To register the add-in, load the solution for the add-in into Visual Studio and follow the instructions in the next section, "Installing an Add-in". After an add-in is registered, the Visual Studio IDE recognizes it. To list it in the Add-in Manager dialog box, there must be as set of registry keys for it, as shown in Listing 2-5.

Listing 2-5: Registry Keys for the Add-in

start example
 HKEY_LOCAL_MACHINE     SOFTWARE         MICROSOFT             VISUAL STUDIO                 7.0                     ADDINS                         MyAddinTest1 (ProgID-Internal Name of Add-in) 
end example

It is sometimes useful to know what the registry keys the Add-in Wizard creates look like. The Add-in Wizard and the Installation Wizard create a unique programmatic ID (ProgID) for each add-in and insert it into the registry. A ProgID consists of the name of the project followed by a period and the name of the class module, such as MyAddinTest1.Connect. As shown earlier in Figure 2-9, Visual Studio stores this registry information in the following keys.


In the release documentation, the key for this is listed as HKEY_ CURRENT_USER, but in reality, the key is generated in HKEY_LOCAL_ MACHINE. Obviously, the documentation or the root key will probably change in a future update of the system.

Listing 2-5 shows the registry key structure for the registered add-in.

Each ProgID contains the following name/value pairs:

  • Friendly name: The name that appears in the Add-in Manager's Available Add-ins list. This value is optional, but it should be used.

  • Description: A string that displays at the right of the Add-in Manager dialog box. This value is optional, but it should be supplied.

  • LoadBehavior: A DWORD bit field with the following optional values:

    • ID_UNLOADED - 0: The add-in should be unloaded immediately.

    • ID_STARTUP - 1: The add-in should be loaded at IDE startup.

    • ID_COMMAND_LINE - 4: The add-in should be loaded via the devenv command line.

  • CommandPreload: ABoolean value that indicates whether it is the first time that Visual Studio has started since the add-in was loaded. "0" specifies that Visual Studio has started more than once since the add-in was loaded. "1" specifies that Visual Studio has not started since the add-in was loaded. When Visual Studio starts, you can pass ext_cm_UISetup to its OnConnection method's ConnectMode argument, provided these conditions are met: You either load an add-in, or it is marked to load at start-up, and its CommandPreload setting is 1. After that, you can check to see if the type of connection is ext_cm_UISetup. If it is, you can perform whatever task you want, such as putting a command on the toolbar, or using Commands.AddNamedCommand or Command.AddControl.

  • CommandLineSafe: Indicates whether the add-in was designed to avoid displaying a UI when invoked by the development environment command line.

  • SatelliteDllPath: If present, the value is a string that is a full pathname to a directory, ending with a backslash (\). The Add-in Manager looks for the concatenation of SatelliteDllPath, the locale ID of the installed machine, the backslash, and SatelliteDllName.

  • SatelliteDllName: The value is a string that names a file. The directory containing the file is either the directory containing the DLL that constitutes the add-in or the computed directory described for SatelliteDllPath.

 < Free Open Study > 

Writing Add-Ins for Visual Studio  .NET
Writing Add-Ins for Visual Studio .NET
ISBN: 1590590260
EAN: 2147483647
Year: 2002
Pages: 172
Authors: Les Smith © 2008-2017.
If you may any questions please contact us: