Creating Callback Objects Example

[This topic applies to UMDF 1.x.]

The following code example shows how a driver creates a device callback object in the implementation of its IDriverEntry::OnDeviceAdd method and then passes a pointer to the device callback interface in its call to the IWDFDriver::CreateDevice method to create the device.

   HRESULT CMyDriver::OnDeviceAdd(
              IWDFDriver*           pDriver,
              IWDFDeviceInitialize* pDeviceInit
              ) {
      IUnknown *pDeviceCallback = NULL;
      HRESULT hr;
      // Create callback object
      hr = CMyDevice::CreateInstance( &pDeviceCallback,
                                      completionPort );
      // Create WDF device
      hr = pDriver->CreateDevice( pDeviceInit, 
                                  &pIWDFDevice );



Send comments about this topic to Microsoft

© 2015 Microsoft