This section describes how to write device drivers for USB devices running on Windows CE. USB device drivers exist to make the services of peripheral devices available to applications. Although there are no standard mechanisms that USB devices must use to accomplish this, there are various strategies that USBDs can adopt, depending on the nature of the peripherals that they control:
A USBD can expose the stream interface functions. Applications can then treat the peripheral device as a file and use standard file I/O functions to interact with the device. However, because the Device Manager is not involved in the loading and unloading of USBDs, any USBD that exposes the stream interface functions must register and deregister its special device file name manually, using the RegisterDevice and DeregisterDevice functions. These functions should be called when the USBD is loaded and unloaded, respectively.
By interacting with a Windows CE API, USB device drivers can indirectly expose certain types of peripheral to applications if Windows CE has an existing API appropriate to the peripheral. For example, USBDs for mass storage devices, such as hard drives and CD-ROM drives, can expose such devices through the standard installable file system interface. The sample USB mouse driver also uses this strategy. The driver does not expose the mouse device directly to applications; instead, it interacts with existing Windows CE APIs to submit the correct input events to the system. Thus, the USB nature of the mouse device is transparent to applications.
This strategy does not place any restrictions on the way that a USBD exposes a device. It allows you to create an API for the device that best maps to the ways that applications are likely to use it. However, you must provide appropriate documentation to application writers so that their applications can use the driver.