Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

SetService method

Adds a service provider to the Transform Factory.


HRESULT retVal = object.SetService(guidService, pUnkService, bWeakReference);


guidService [in]


GUID used to identify the service.

pUnkService [in]

Type: IUnknown

Pointer to a service provider interface.

bWeakReference [in]

Type: BOOL

Flag that indicates whether the reference to the service provider object should be a weak reference. If TRUE, the reference is weak; otherwise, the reference is strong. A strong reference causes the factory to reference count the service. A weak reference should be requested where there is potential for cyclic dependencies. See Remarks for more information.


To remove the service specified by guidService, set the pUnkService parameter to NULL.

A strong reference —also called a lock— keeps an object active and running. As long as a strong reference to an object exists, the object should not shut down. A weak reference does not prevent an object from shutting down. For example, if a client is using a child process, its parent must stay running because the child cannot exist independent of the parent. When there is a strong reference on the child, the child holds a strong reference on the parent. But if a client is not using the child, the simple existence of the child should not keep the parent active.

In a normal state, the parent should hold a weak reference on the child. Thus, when all clients release the child, the child shuts down because there are no other strong references. This is usually handled by maintaining a lock count on the object separate from the reference count. When the lock count is zero, the object attempts to also make its reference count zero, for example, by sending a close notification and disconnecting all external connections.



© 2015 Microsoft