增加框架中的全局活动对象的数量。
void AFXAPI AfxOleLockApp( );
备注
框架在应用程序保留对象的数目的计数活动。 AfxOleLockApp 和 AfxOleUnlockApp 函数分别,递增和递减此计数。
当用户尝试关闭有活动对象 (的应用程序时计算活动对象是非零的应用程序框架) 隐藏从用户查看的应用程序而非完整关闭它。 AfxOleCanExitApp 函数用于指示应用程序是否可以停止。
调用从 OLE 接口公开的所有对象的 AfxOleLockApp,因此,如果不需要的。将销毁该对象,同时也使用由客户端应用程序时。 请调用并在调用构造函数中 AfxOleLockApp 的所有对象的析构函数的 AfxOleUnlockApp。 默认情况下,派生类 ( COleDocument 和) 会自动锁定和取消锁定应用程序。
示例
// 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();
}
要求
Header: <afxdisp.h>