Skip to content

Latest commit

 

History

History
102 lines (66 loc) · 4.83 KB

nf-wudfddi-iwdfobject-assigncontext.md

File metadata and controls

102 lines (66 loc) · 4.83 KB
UID title description old-location tech.root ms.date keywords 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 f1_keywords topic_type api_type api_location api_name
NF:wudfddi.IWDFObject.AssignContext
IWDFObject::AssignContext (wudfddi.h)
The AssignContext method registers a context and a driver-supplied cleanup callback function for the object.
wdf\iwdfobject_assigncontext.htm
wdf
02/26/2018
IWDFObject::AssignContext
AssignContext, AssignContext method, AssignContext method,IWDFObject interface, IWDFObject interface,AssignContext method, IWDFObject.AssignContext, IWDFObject::AssignContext, UMDFBaseObjectRef_1cc8c14a-66bd-487c-a58d-00f22f52adcc.xml, umdf.iwdfobject_assigncontext, wdf.iwdfobject_assigncontext, wudfddi/IWDFObject::AssignContext
wudfddi.h
Wudfddi.h
Desktop
1.5
Unavailable in UMDF 2.0 and later.
WUDFx.dll
Windows
IWDFObject::AssignContext
wudfddi/IWDFObject::AssignContext
APIRef
kbSyntax
COM
WUDFx.dll
IWDFObject::AssignContext

IWDFObject::AssignContext

-description

[Warning: UMDF 2 is the latest version of UMDF and supersedes UMDF 1. All new UMDF drivers should be written using UMDF 2. No new features are being added to UMDF 1 and there is limited support for UMDF 1 on newer versions of Windows 10. Universal Windows drivers must use UMDF 2. For more info, see Getting Started with UMDF.]

The AssignContext method registers a context and a driver-supplied cleanup callback function for the object.

-parameters

-param pCleanupCallback [in, optional]

A pointer to the IObjectCleanup interface that contains the cleanup callback function, which performs cleanup operations for the object if it becomes invalid. This parameter is optional. The driver can pass NULL if the driver does not require notification when the object is cleaned up.

-param pContext [in, optional]

A pointer to the context to register. NULL is a valid context.

-returns

AssignContext returns S_OK if the operation succeeds. Otherwise, this method returns one of the error codes that are defined in Winerror.h.

-remarks

A driver calls AssignContext to register a context and to request notification when the object becomes invalid. In a AssignContext call, the driver passes a pointer to the IObjectCleanup interface in the pCleanupCallback parameter to register IObjectCleanup. Note that the framework internally holds a reference to the supplied IObjectCleanup interface while the object is valid. When the object becomes invalid, the framework calls the IObjectCleanup::OnCleanup method to notify the driver. The framework automatically releases the reference to the supplied IObjectCleanup after calling IObjectCleanup::OnCleanup.

At any given time, only one context that is associated with each object instance can exist. Attempts to register additional contexts fail.

A context can be associated only with an object that is in a valid state. For example, an attempt to associate a context with an object that is in the process of deletion fails.

Because the context is not a Component Object Model (COM) interface, the driver must not treat the context as such. For example, the driver cannot call the AddRef method on the context.

The IWDFObject::RetrieveContext method can be used to retrieve the context that was previously registered through AssignContext.

Examples

For a code example of how to use the AssignContext method, see IWDFIoTarget::FormatRequestForWrite.

-see-also

IObjectCleanup

IObjectCleanup::OnCleanup

IWDFObject

IWDFObject::RetrieveContext