增加活动对象的数量的结构的全局计数在应用程序中。
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>