8.2.4 OleRegisterServer

OLESTATUS OleRegisterServer(lpszClass, lpsrvr, lplhserver, hInst, srvruse)

LPCSTR lpszClass;

LPOLESERVER lpsrvr;

LHSERVER FAR * lplhserver;

HINSTANCE hInst;

OLE_SERVER_USE srvruse;

The OleRegisterServer function registers the specified server, class name, and instance with the server DLL.

Parameter Description

lpszClass Points to a null-terminated string specifying the class name being registered.
lpsrvr Points to an OLESERVER structure allocated and initialized by the server application.
lplhserver Points to a variable of type LHSERVER in which the DLL stores the handle to the server. This handle is used in such functions as OleRegisterServerDoc and OleRevokeServer.
hInst Identifies the instance of the server application. This handle is used to ensure that clients connect to the correct instance of a server application.
srvruse Specifies whether the server uses a single instance or multiple instances to support multiple objects. This value must be either OLE_SERVER_SINGLE or OLE_SERVER_MULTI.

When the server application starts, it creates an OLESERVER structure and calls the OleRegisterServer function. Servers that support several class names can allocate a structure for each or reuse the same structure. The class name is passed to server-application functions that are called through the DLL, so that servers supporting more than one class can check which class is being requested.

The srvruse parameter is used when the libraries open an object. When OLE_SERVER_MULTI is specified for this parameter, a new instance of the server is started if all current instances are already editing an object. Servers that support the multiple document interface (MDI) typically specify OLE_SERVER_SINGLE.

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

OLE_ERROR_PROTECT_ONLY

OLE_ERROR_CLASS

OLE_ERROR_MEMORY

See AlsoOleRegisterServerDoc, OleRevokeServer