3ds Max provides hooks into its SDK that allow events such as scene saving/loading, undo/redo, Max startup/shutdown, object creation and many others to be called into the plugins. This is a very useful functionality that allows plugins to be responsive to 3dsmax UI rather than just rely on its own UI.
Here is a simple way to register and, optionally, unregister such an event callback as a delegate in your C# code:
void Global_SystemShutdown( IntPtr obj, IntPtr info )
{
// Do something...
}
GlobalDelegates.Delegate3 systemShutdownHandler;
this.systemShutdownHandler = new GlobalDelegates.Delegate3( this.Global_SystemShutdown );
global.RegisterNotification( this.systemShutdownHandler, null, SystemNotificationCode.SystemShutdown );
global.UnRegisterNotification( this.systemShutdownHandler, null, SystemNotificationCode.SystemShutdown );
That is all there is to it! Have a look at SystemNotificationCode enumeration for a list of available global events.