Hardware Dev Center

IDriverEntry::OnDeviceAdd method

[Applies to UMDF 1.x only]

The OnDeviceAdd method adds a new device to a system.


HRESULT OnDeviceAdd(
  [in] IWDFDriver           *pWdfDriver,
  [in] IWDFDeviceInitialize *pWdfDeviceInit


pWdfDriver [in]

A pointer to the IWDFDriver interface for the parent driver object that the new device belongs to.

pWdfDeviceInit [in]

A pointer to the IWDFDeviceInitialize interface that the driver uses to initialize the newly created device.

Return value

OnDeviceAdd returns S_OK if the operation succeeds. Otherwise, this method returns one of the error codes that are defined in Winerror.h. The driver should return S_OK only if it successfully called the IWDFDriver::CreateDevice method to create the framework device object. If the driver returns an error code, UMDF tears down the entire device stack regardless of whether the driver is a filter driver or a function driver.


A new device object is created for each device that is loaded in the driver host process. When a new device arrives in the system, the framework calls OnDeviceAdd to notify the driver of the arrival and passes the IWDFDriver and IWDFDeviceInitialize interfaces in the call. The driver can call the IWDFDeviceInitialize::RetrieveDevicePropertyStore method to query for the device information that is provided as part of device installation. The driver must call the IWDFDriver::CreateDevice method to configure and create the device. If the driver does not successfully call IWDFDriver::CreateDevice before it returns S_OK, UMDF determines that the driver's behavior is incorrect and terminates the host process.

Any driver whose OnDeviceAdd method returns S_OK will subsequently receive a call to its IPnpCallbackHardware::OnReleaseHardware method when the UMDF tears down the device stack.

Do not use the IWDFDeviceInitialize interface that the pWdfDeviceInit parameter points to after the driver has called IWDFDriver::CreateDevice.

For more information, see Adding a Device.



Wudfddi.h (include Wudfddi.h)

See also




Send comments about this topic to Microsoft

© 2015 Microsoft