IOleContainer::LockContainer
Keeps an
embedded object s container running.
HRESULT LockContainer(
BOOL fLock |
//Value indicating lock or unlock |
); |
|
Parameter
fLock
[in] Value
that specifies whether to lock (TRUE) or unlock (FALSE) a container.
Return Values
This method
supports the standard return values E_FAIL and E_OUTOFMEMORY, as well as the
following:
S_OK
Container was
locked successfully.
Remarks
An embedded
object calls IOleContainer::LockContainer to keep its container
running when the object has link clients that require an update. If an end user
selects File Close from the container s menu, however, the container ignores
all outstanding LockContainer locks and closes the document anyway.
Notes to Callers
When an
embedded object changes from the loaded to the running state, it should call IOleContainer::LockContainer
with the fLock parameter set to TRUE. When the embedded object shuts
down (transitions from running to loaded), it should call IOleContainer::LockContainer
with the fLock parameter set to FALSE.
Each call to LockContainer
with fLock set to TRUE must be balanced by a call to LockContainer
with fLock set to FALSE. Object applications typically need not call LockContainer;
the default handler makes these calls automatically for object applications
implemented as .EXEs as the object makes the transition to and from the running
state. Object applications not using the default handler, such as DLL object
applications, must make the calls directly.
An object
should have no strong locks on it when it registers in the Running Object
Table, but it should be locked as soon as the first external client connects to
it. Therefore, following registration of the object in the Running Object
Table, object handlers and DLL object applications, as part of their
implementation of IRunnableObject::Run
Notes to Implementers
The container
must keep track of whether and how many calls to LockContainer(TRUE)
have been made. To increment or decrement the reference count, IOleContainer::LockContainer
calls CoLockObjectExternal
See Also