Compartilhar via


IClassFactory::LockServer (Windows Embedded CE 6.0)

1/6/2010

This method locks an object application open in memory. This allows new objects to be created more quickly.

Syntax

HRESUTL LockServer( 
  BOOL fLock
);

Parameters

  • fLock
    [in] Boolean value that is set to TRUE to increment the lock count, or to FALSE to decrements the lock count.

Return Value

This method supports the standard return values E_FAIL, E_OUTOFMEMORY, and E_UNEXPECTED, as well as S_OK, which indicates that the specified object was either locked (fLock = TRUE) or unlocked from memory (fLock = FALSE).

Remarks

IClassFactory::LockServer controls whether an object's server is kept in memory. Keeping the application alive in memory allows instances to be created more quickly.

To determine whether the platform supports this interface, see Determining Supported COM APIs.

Notes to Callers

Most clients do not need to call this function. It is provided only for those clients that require special performance in creating multiple instances of their objects.

Notes to Implementers

If the lock count is zero, there are no more objects in use, and the application is not under user control, the server can be closed.

The process that locks the object application is responsible for unlocking it. Once the class object is released, there is no mechanism that guarantees the caller connection to the same class later (as in the case where a class object is registered as single-use).

It is important to count all calls, not just the last one, to IClassFactory::LockServer, because calls must be balanced before attempting to release the pointer to the IClassFactory interface on the class object or an error results.

For every call to LockServer with fLock set to TRUE, there must be a call to LockServer with fLock set to FALSE.

When the lock count and the class object reference count are both zero, the class object can be freed.

Requirements

Header ocidl.h, ocidl.idl
Library ole32.lib, uuid.lib
Windows Embedded CE Windows CE 2.0 and later

See Also

Reference

IClassFactory