Sample Code
Windows Driver Samples/ Toaster Sample Driver/ C++/ umdf/ func/ Device.h/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | /*++ Copyright (c) Microsoft Corporation, All Rights Reserved Module Name: Device.h Abstract: This file contains the class definition for device callback object. Environment: Windows User-Mode Driver Framework (UMDF) --*/ #pragma once #include "resource.h" #include "WUDFToaster.h" // // To inform the framework about the callbacks we are interested in, we // simply derive from the desired set of interfaces. // class CDevice : public IPnpCallbackHardware { public : CDevice() : m_cRefs(0) { } public : // // Static method that creates a device callback object. // static HRESULT CreateInstance(_Out_ IUnknown ** ppUnkwn) { *ppUnkwn = NULL; #pragma warning( suppress : 6014 )// PFD ISSUE: counted memory locks CDevice *pMyDevice = new CDevice(); if (NULL == pMyDevice) { return E_OUTOFMEMORY; } return (pMyDevice->QueryInterface( __uuidof(IUnknown), ( void **) ppUnkwn )); } // // IUnknown // virtual HRESULT __stdcall QueryInterface(_In_ REFIID riid, _Out_ LPVOID * ppvObject); virtual ULONG __stdcall AddRef(); _At_( this , __drv_freesMem(object)) virtual ULONG __stdcall Release(); // IPnpCallbackHardware // virtual HRESULT __stdcall OnPrepareHardware(_In_ IWDFDevice* pDevice); virtual HRESULT __stdcall OnReleaseHardware(_In_ IWDFDevice* pDevice); // // TODO: Add your interfaces here // private : LONG m_cRefs; }; |
Our Services
-
What our customers say about us?
Read our customer testimonials to find out why our clients keep returning for their projects.
View Testimonials