MFC
TRY
Erweitern Minimieren
Dieser Artikel wurde noch nicht bewertet - Dieses Thema bewerten.

AfxOleLockApp

Increments the framework's global count of the number of active objects in the application.


void AFXAPI AfxOleLockApp( );

The framework keeps a count of the number of objects active in an application. The AfxOleLockApp and AfxOleUnlockApp functions, respectively, increment and decrement this count.

When the user attempts to close an application that has active objects — an application for which the count of active objects is nonzero — the framework hides the application from the user's view instead of completely shutting it down. The AfxOleCanExitApp function indicates whether the application can terminate.

Call AfxOleLockApp from any object that exposes OLE interfaces, if it would be undesirable for that object to be destroyed while still being used by a client application. Also call AfxOleUnlockApp in the destructor of any object that calls AfxOleLockApp in the constructor. By default, COleDocument (and derived classes) automatically lock and unlock the application.

// 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.

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

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

Header: <afxdisp.h>

Fanden Sie dies hilfreich?
(1500 verbleibende Zeichen)
Microsoft führt eine Onlineumfrage durch, um Ihre Meinung zur MSDN-Website zu erfahren. Wenn Sie sich zur Teilnahme entscheiden, wird Ihnen die Onlineumfrage angezeigt, sobald Sie die MSDN-Website verlassen.

Möchten Sie an der Umfrage teilnehmen?
© 2013 Microsoft. Alle Rechte vorbehalten.