Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
OnPrepareHardware method
Collapse the table of content
Expand the table of content

IPnpCallbackHardware::OnPrepareHardware method

[Applies to UMDF 1.x only]

The OnPrepareHardware method notifies a driver to make the specified hardware accessible.


HRESULT OnPrepareHardware(
  [in] IWDFDevice *pWdfDevice


pWdfDevice [in]

A pointer to the IWDFDevice interface for the device object of the device to make accessible.

Return value

OnPrepareHardware returns S_OK if the operation succeeds. Otherwise, this method returns one of the error codes defined in Winerror.h. Do not return HRESULT_FROM_NT(STATUS_NOT_SUPPORTED).

If OnPrepareHardware returns an error code, the framework will still call the IPnpCallbackHardware::OnReleaseHardware method. The OnReleaseHardware method can then free resources that were allocated during the call to OnPrepareHardware. Because OnReleaseHardware must free resources for both success and failure cases of OnPrepareHardware, it must be able to handle the cleanup of partial resources.

This method must use the HRESULT_FROM_NT macro to return a specific HRESULT value to return status to a kernel-mode client. For more information, see Supporting Kernel-mode Clients.


A driver registers the IPnpCallbackHardware interface when it calls the IWDFDriver::CreateDevice method to create a device object.

Receiving a call to the OnPrepareHardware method is equivalent to a Microsoft Windows Driver Model (WDM) driver receiving an IRP_MN_START_DEVICE IRP.

For more information, see Finding and Mapping Hardware Resources in a UMDF Driver.



Wudfddi.h (include Wudfddi.h)

See also




Send comments about this topic to Microsoft

© 2015 Microsoft