title | description | keywords | ms.date | |
---|---|---|---|---|
Creating Callback Objects Example |
Creating Callback Objects Example |
|
04/20/2017 |
[!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 );
...
}