Export (0) Print
Expand All
Cut
Run
Expand Minimize

OnBeginShutdown Method

Visual Studio .NET 2003

Occurs when the environment is being shut down.

[Visual Basic .NET]
Public Sub OnBeginShutdown( _
   ByVal custom() As Variant _
) 
[Visual Basic 6]
Sub OnBeginShutdown( _
   ByVal custom() As Variant _
) 
[C++]
HRESULT __stdcall OnBeginShutdown(
   SAFEARRAY** custom
);
[C#]
void OnBeginShutdown(
   object[] custom
);
[JScript .NET]
public function OnBeginShutdown(
   custom : Object[]
)

Parameters

custom
An array of Variants that you can use to provide additional data.

Remarks

OnBeginShutdown is a method that, when its host interface is implemented, acts as an event that occurs while the environment is being shut down.

The OnBeginShutdown event occurs when a host application begins its shutdown routines; that is, when a application closes while the Add-in is still loaded. If the Add-in is not currently loaded when the application closes, the OnBeginShutdown event does not occur. When this event does occur, it occurs before the OnDisconnection event.

You can use the OnBeginShutdown event procedure to run code when the user closes an application. For example, you can run code that saves form data to a file.

It is possible that OnBeginShutdown can occur more than once. If an event handler cancels the environment shutdown, the next time the environment begins to shut down, OnBeginShutdown will occur again.

Example

Note that this code works only in an Add-In project, not in macros.

Imports Microsoft.Office.Core
imports Extensibility
imports System.Runtime.InteropServices
Imports EnvDTE

<GuidAttribute("B25D9733-A1B2-420D-8F6B-478E2B051C83"), ProgIdAttribute("MyAddin1.Connect")> _
Public Class Connect
   Implements Extensibility.IDTExtensibility2

   Dim applicationObject As EnvDTE.DTE
   Dim addInInstance as EnvDTE.AddIn
   
   Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown
      Msgbox("Shutdown event occuring.")
   End Sub
End Class

See Also

OnAddInsUpdate Method | OnConnection Method | OnDisconnection Method | OnStartupComplete Method

Applies To: IDTExtensibility2 Interface

Show:
© 2014 Microsoft