All USB device drivers must expose certain entry points in their DLLs to interact properly with the USBD module. The following entry points not only enable the USBD module to connect a driver with its peripheral, but also enable a driver to create and manage any registry keys it may need:
The USBD module calls this function when the USB device is connected to a host computer. The driver’s implementation of this function can decline to control the device, in which case the USBD module attempts to find another driver to handle the device. A driver rarely declines to control a device, though it might under certain conditions. For example, the driver might decline to control the device if the driver can determine from the device configuration block that the device is newer than the driver. By doing so, the driver indirectly gives the user an opportunity to enter the name of the correct USBD DLL if Windows CE cannot locate another driver for the device. For more information, see USB Device Driver Attach Processing.
This function, which is called the first time that the USB device driver is loaded, allows the driver to create any registry keys that it needs. For more information on the format of these keys and how they are used to load USBDs, see USB Device Driver Load Process.
This function is called when the user removes the driver from a Windows CE–based platform. It is responsible for removing all registry keys created by the driver’s USBInstallDriver function and for releasing any other resources held by the driver. For more information, see Removing USB Device Drivers.