Skip to content

Latest commit

 

History

History
38 lines (30 loc) · 1.31 KB

creating-callback-objects-example.md

File metadata and controls

38 lines (30 loc) · 1.31 KB
title description keywords ms.date
Creating Callback Objects Example
Creating Callback Objects Example
callback objects WDK UMDF , example of creating
04/20/2017

Creating Callback Objects Example

[!includeUMDF 1 Deprecation]

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,
                                      pDeviceInit,
                                      completionPort );
      ...
      // Create WDF device
      hr = pDriver->CreateDevice( pDeviceInit, 
                                  pDeviceCallback,
                                  &pIWDFDevice );
      ...
   }