Condividi tramite


Visual Basic Concepts

Registering Add-Ins

As an ActiveX component, an add-in must be properly registered in the system registry before it can be recognized or used by any Windows program, including Visual Basic. The process of compiling the add-in in Visual Basic automatically registers it on your system, but anyone who intends to use your add-in on another system must register it there before they can use it.

This means that if the add-in is an in-process component (.dll file), you (or your customer) must use a utility such as Regsvr32.exe to register it on their system. For ease of use to the customer, you would normally do this in the add-in’s setup program.

If the add-in is an out-of-process component (.exe file), running the .exe file registers it. If you’d rather register the add-in without running it, add the /regserver parameter to the .exe file’s command line, such as when you're creating a setup:

MyAddIn /regserver

When the add-in reference is written to the system registry, the registered name is the programmatic ID — comprised of the name of your add-in project (as shown in the Project Name box on the General tab of the Project Properties dialog box) plus the name of the class module that contains the add-in's connect and disconnect event-handling code.

For example, if you create an add-in using the Visual Basic default names — Project1 for the project name and Class1 for the class module name — then the registered name of the add-in will be Project1.Class1.