#include <ole.h> |
OLESTATUS OleRegisterServer(lpszClass, lpsrvr, lplhserver, hinst, srvruse) | |||||
LPCSTR lpszClass; | /* address of string for class name | */ | |||
LPOLESERVER lpsrvr; | /* address of OLESERVER structure | */ | |||
LHSERVER FAR* lplhserver; | /* address of server handle | */ | |||
HINSTANCE hinst; | /* instance handle, */ | ||||
OLE_SERVER_USE srvruse; | /* single or multiple instances | */ |
The OleRegisterServer function registers the specified server, class name, and instance with the server library.
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 library stores the handle of 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.
The return value is OLE_OK if the function is successful. Otherwise, it is an error value, which may be one of the following:
OLE_ERROR_CLASS
OLE_ERROR_MEMORY
OLE_ERROR_PROTECT_ONLY
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 library, 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 and all current instances are already editing an object, a new instance of the server is started. Servers that support the multiple document interface (MDI) typically specify OLE_SERVER_SINGLE.