Skip to content

Latest commit

 

History

History
85 lines (64 loc) · 4.49 KB

nf-combaseapi-coaddrefserverprocess.md

File metadata and controls

85 lines (64 loc) · 4.49 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:combaseapi.CoAddRefServerProcess
CoAddRefServerProcess function (combaseapi.h)
Increments a global per-process reference count.
CoAddRefServerProcess
CoAddRefServerProcess function [COM]
_com_CoAddRefServerProcess
com.coaddrefserverprocess
combaseapi/CoAddRefServerProcess
com\coaddrefserverprocess.htm
com
79887f9d-cad1-492a-b406-d1753ffaf82b
12/05/2018
CoAddRefServerProcess, CoAddRefServerProcess function [COM], _com_CoAddRefServerProcess, com.coaddrefserverprocess, combaseapi/CoAddRefServerProcess
combaseapi.h
Objbase.h
Windows
Windows 2000 Professional [desktop apps only]
Windows 2000 Server [desktop apps only]
Ole32.lib
Ole32.dll
Windows
19H1
CoAddRefServerProcess
combaseapi/CoAddRefServerProcess
c++
APIRef
kbSyntax
DllExport
Ole32.dll
API-MS-Win-Core-Com-l1-1-0.dll
ComBase.dll
API-MS-Win-Core-Com-l1-1-1.dll
API-MS-Win-DownLevel-Ole32-l1-1-1.dll
CoAddRefServerProcess

CoAddRefServerProcess function

-description

Increments a global per-process reference count.

-returns

The current reference count.

-remarks

Servers can call CoAddRefServerProcess to 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 CoAddRefServerProcess increments a global per-process reference count, and calling CoReleaseServerProcess decrements 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 functions is to call CoAddRefServerProcess in the constructor for each of its instance objects, and in each of its IClassFactory::LockServer methods when the fLock parameter is TRUE. The server application should also call CoReleaseServerProcess in the destruction of each of its instance objects, and in each of its LockServer methods when the fLock parameter is FALSE. Finally, the server application should pay attention to the return code from CoReleaseServerProcess and 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 CoRevokeClassObject and CoUninitialize.

If these functions are used at all, they must be called in both the object instances and the LockServer method, otherwise the server application may be shut down prematurely. In-process servers typically should not call CoAddRefServerProcess or CoReleaseServerProcess.

-see-also

CoReleaseServerProcess

IClassFactory::LockServer

Out-of-Process Server Implementation Helpers