Writing a Driver to detect presence of a USB device.

Hello, I am relatively new to writing driver programs. I am currently working on a project and need to write a driver for that. For starting I need to write a driver that detects if a USB device is present or not. I have been reading the documentation but cannot figure out the code to start with. Your guidance is appreciated. Thank you

abhieshekumar wrote:

Hello, I am relatively new to writing driver programs. I am currently working on a project and need to write a driver for that. For starting I need to write a driver that detects if a USB device is present or not. I have been reading the documentation but cannot figure out the code to start with.

You do not use a driver for this.  A driver just focuses on the one
device it is designed to drive.  The APIs to scan through the tree of
devices are all in user mode, including the SetupDI APIs and the
lower-level CfgMgr APIs (like CM_Get_Device_ID_List).  The “devcon” tool
in the Windows Driver Samples demonstrates how to do this in great detail.