The OnDisconnection Method

Home Page (Add-ins)OverviewHow Do I TopicsFAQReference

When Visual C++ shuts down, the environment unloads each add-in by calling the OnDisconnection method. If you use the Developer Studio Add-in Wizard to create an add-in, the wizard automatically creates the code that implements the OnDisconnection method. In this code, the OnDisconnection method is in the CDSAddIn class located in the Dsaddin.cpp file.

The syntax for the OnDisconnection method is:

voidOnDisconnection ( VARIANT_BOOLbLastTime )

To disconnect, the add-in does the following:

  1. Examines the bLastTime parameter to determine why it is unloading. VARIANT_TRUE means that the user is removing (uninstalling) it. VARIANT_FALSE means only that the Visual C++ environment is exiting.

  2. Disconnects from events.

  3. Releases the pointer (Application*) to the dual interface on the Developer Studio Application object — if it stored the pointer while connecting to the environment.

  4. Performs housekeeping tasks such as deallocating memory, freeing resources, and so on.