9.8.2 OleLockServer

OLESTATUS OleLockServer(lpObject, lphServer)

LPOLEOBJECT lpObject;

LHSERVER FAR * lphServer;

The OleLockServer function is called by a client application to keep an open server application in memory.

Parameter Description

lpObject Points to an object the client DLL uses to identify the open server application to keep in memory.
lphServer Points to a handle to the server application when the function returns.

Keeping the server application in memory allows the client DLL to use the server application to open objects quickly.

A client calls the OleLockServer function to speed the opening of objects when the same server is used for a number of different objects. Before the client terminates, it must call the OleUnlockServer function to release the server from memory.

When the server has been locked, this object can be deleted. When OleLockServer is called more than once for a given server, even by different client applications, the server's lock count is increased. Each call to the OleUnlockServer function decrements the lock count. The server remains locked until the lock count is zero. If the object identified by the lpObject parameter is deleted before calling the OleUnlockServer function, OleUnlockServer must still be called to decrement the lock count.

A server can terminate even though a client has called the OleLockServer function, if necessary.

The return value is OLE_OK if successful; otherwise, it could be one of the following:

OLE_ERROR_COMM

OLE_ERROR_LAUNCH

OLE_ERROR_OBJECT

OLE_ERROR_MEMORY

OLE_ERROR_STATIC

See AlsoOleUnlockServer