Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This function increments a global per-process reference count.
Syntax
ULONG CoAddRefServerProcess(void); |
Parameters
None.
Return Value
- S_OK
-
The CLSID was retrieved successfully.
Remarks
Servers can call CoAddRefServerProcessto increment a global per-process reference count.
This function is particularly helpful to servers that are implemented with multiple threads, either multi-apartmented or free-threaded. Servers of these types must coordinate the decision to shut down with activation requests across multiple threads.
Calling CoAddRefServerProcessincrements a global per-process reference count, and calling CoReleaseServerProcessdecrements that count.
When that count reaches zero, OLE automatically calls CoSuspendClassObjects, which prevents new activation requests from coming in. This permits the server to deregister its class objects from its various threads without worry that another activation request may come in.
New activation requests result in launching a new instance of the local server process.
The simplest way for a local server application to make use of these API functions is to call CoAddRefServerProcessin the constructor for each of its instance objects, and in each of its IClassFactory::LockServermethods when the fLockparameter is TRUE.
The server application should also call CoReleaseServerProcessin the destruction of each of its instance objects, and in each of its IClassFactory::LockServermethods when the fLockparameter is FALSE.
Finally, the server application should pay attention to the return code from CoReleaseServerProcessand if it returns 0, the server application should initiate its cleanup, which, for a server with multiple threads, typically means that it should signal its various threads to exit their message loops and call CoRevokeClassObjectand CoUninitialize.
If these functions are used at all, they must be called in both the object instances and the LockServermethod; otherwise, the server application may be shut down prematurely. In-process servers typically should not call CoAddRefServerProcessor CoReleaseServerProcess.
To determine whether the platform supports this function, see Determining Supported COM APIs.
Requirements
Header | objbase.h |
Library | ole32.lib |
Windows Embedded CE | Windows CE 3.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |