How to Create a Device Driver

After you create a platform, you can create a device driver for a specific target device to operate under the Windows CE operating system (OS). You create your driver once you have identified the hardware platform that you want use with the OS.

Hardware and Software Assumptions

  • The sample driver code demonstrated in the following steps is merely a starting point and does not actually work with specific hardware. You must modify the driver code in order for it to function correctly for your target device.
  • You are familiar with building Platform Builder projects from the command line. For more information, see Build Tool.
  • You are familiar with editing sources files. For more information, see Sources File.
  • You are creating a power-managed stream interface driver. For more information about stream interface drivers, see Stream Interface Drivers. For more information about power management, see Device Power Management Enabling.

To track your progress in the following table, select the check box next to each step.

  Step Topic
1. If you have not already done so, in the Platform Builder integrated development environment (IDE), create a platform. Creating a Platform
2. Copy the power management development sample driver to your platform.

For example, copy %SystemRoot%\WINCE420\Public\Common\Oak\Drivers\PM\Test\Devsample to %_WINCEROOT%\Platform\<your platform>\drivers\mydriver.

For future reference, rename the files in the Devsample directory to names that correspond with the intended functionality of your driver.

Not applicable
3. Add WINCEOEM=1 to the sources file for your driver to allow your driver access to public projects. Not applicable
4. Modify the source code to implement the correct stream interface and power management functions for your target device.

Because you previously created your driver, proceed to step 2 in the corresponding topic.

How to Add Power Management to a Device Driver
5. Add registry information for your driver to the Platform.reg file for your platform.

For example, you can add the following code example to the Platform.reg file to specify the correct registry information for your driver.

#include "$(_winceroot)\platform\<your platform>\drivers\mydriver\mydriver.reg"
Registry File
6. Modify the Platform.bib file for your platform to include your driver.

For example, you can add the following code example to the Modules section of the Platform.bib file to specify the correct location of your driver.

MyDriver.dll    $(_FLATRELEASEDIR)\MyDriver.dll          NK SH
Binary Image Builder File
7. Edit the dirs file for your platform to include your driver in your platform. Dirs File
8. From %_WINCEROOT%\Platform\CEPC\Drivers\mydriver in your platform, build your driver. Building a Device Driver from the Command Line
9. In the IDE, build your platform to include your driver. Building a Platform
10. Debug the source code for your driver.

If you can successfully debug your driver, you have successfully created a driver.

After creating your driver, you may want to test it using the Windows CE .NET Test Kit (CETK). For more information on testing your driver using the CETK, see How to Use the CETK to Test a Driver.

How to Debug a Device Driver

See Also

Driver Development Overview | Troubleshooting a Device Driver | Driver Testing | Driver Code Structure | Device Driver How-to Topics | Stream Interface Drivers | Device Power Management Enabling | Build Tool | Sources File

 Last updated on Tuesday, May 18, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.