AfxOleLockApp

Erhöht die globale Anzahl des Frameworks der Anzahl aktiver Objekte in der Anwendung.

void AFXAPI AfxOleLockApp( );

Hinweise

Das Framework behält die Anzahl der Objekte in einer Anwendung aktiv.Die AfxOleLockApp und Funktionen AfxOleUnlockApp Inkrementieren und dekrementieren diese Anzahl fest.

Wenn der Benutzer versucht, eine Anwendung zu schließen, die aktive — Objekte verfügt eine Anwendung, für die die Anzahl von aktiven Objekten ungleich 0 (null) ist, wird das Framework mithilfe von der Benutzersicht aus, anstatt sie vollständig unten zu schließen.Die AfxOleCanExitApp-Funktion gibt an, ob die Anwendung beendet werden kann.

Rufen Sie AfxOleLockApp von jedem Objekt an, das OLE-Schnittstellen verfügbar macht, wenn unerwünscht sein, damit dieses Objekt zerstört werden kann, während noch von einer Clientanwendung verwendet werden.Rufen Sie auch AfxOleUnlockApp Destruktor eines beliebigen Objekts an, das AfxOleLockApp im Konstruktor aufgerufen wird.Standardmäßig sperren COleDocument (und abgeleitete Klassen) und die Anwendung automatisch entsperrt.

Beispiel

// Below is a code sample from an  Application Wizard-generated SDI 
// Application with Automation support. The Application Wizard adds a 
// dispatch interface to the document class. AfxOleLockApp() and
// AfxOleUnlockApp() respectively increment and decrement the 
// application's object count. When the object count is equal to 
// zero and if the user has not taken control of the application,
// the server is terminated.

CCMFCAutomationDoc::CCMFCAutomationDoc()
{
    EnableAutomation();
    AfxOleLockApp();
}

CCMFCAutomationDoc::~CCMFCAutomationDoc()
{
    AfxOleUnlockApp();
}

Anforderungen

Header: <afxdisp.h>

Siehe auch

Referenz

AfxOleUnlockApp

AfxOleCanExitApp

COleDocument-Klasse

Konzepte

MFC-Makros und -globale Werte