Print Driver Quick Start Sheet

Creating Your Own Printer Driver

The DDK includes sample source code for many Microsoft® Windows® 2000 drivers that you can use as a base for your own driver development. Choose the driver that most closely matches your device and spend some time analyzing and experimenting with it. Please note that the DDK assumes you are conversant with kernel-mode C programming and debugging on Windows 2000.

Compiling Your Driver

Windows 2000 DDK drivers are built using the build utility, which uses a set of rules and project files which specify how drivers should be created.

The dirs file specifies which directories in the subtrees contain source code files that are to be built. The sources file specifies which source files are required to build the current driver.

If your driver will consist of multiple binaries, or the source will be kept in multiple directories, you may need to create a dirs file specifying which directories are to be built and in what order. Each separate binary will require a sources file describing which files are to be compiled/linked to create the driver.

Each driver directory also contains a makefile. As build spawns the nmake utility for each source file listed in sources, nmake uses the makefile to generate dependency and command lists. The standard makefile in a driver source code directory directs nmake to the master nmake macro definition file, makefile.def. This file defines the flags for the build tools such as the compiler and linker. Makefile.def simplifies the creation of platform-independent driver projects and is similar to the ntwin32.mak file in the Win32 SDK.

Once you have your dirs, sources and makefile files created, the next step is to run build. Build will parse the sources file and spawn nmake for each source file. Nmake will evaluate the macros in makefile.def and spawn the C compiler with the proper switches. After the compile stages are completed, build will spawn nmake again to link the objects and complete the driver building phase.

If your sources file is correct, running build is all that is required to compile and link your driver. Using build and makefile.def removes the guesswork from such things as which compiler switches are required, and what arguments the linker requires. By adding the appropriate defines to the sources file, it is possible to control the build options in a platform-independent fashion.

During driver development you will need to build free and checked versions of your driver. This is controlled by environment variable settings which are interpreted by build and nmake. These variables are set by setenv.bat, as discussed previously. To build a free driver, run build from the free environment. To build a checked driver, run build from the checked environment.

Template files (.tpl) for dirs, sources, makefile, and other files can be found in the \destination\doc directory. Working versions of these files can be found in driver source subdirectories of the DDK. Examining these files along with makefile.def (located in the \destination\inc directory) will provide additional information.

For more information about the build utility, see the Windows 2000 Programmer's Guide.

Environment for Compiling Driver Samples

Note: Make sure you set environment specifics for your C development environment first:

set path=%path%;c:\msdev\bin set include=%include%;c:\msdev\include set lib=%lib%;c:\msdev\lib
Then switch to c:\ddk\src\print\ and select the driver to build.

To build, simply type BLD. Note: You may need to run BLD from psprint first.

Logs are in build.log and build.wrn.

Output .dll products are in c:\ddk\lib\i386 unless otherwise noted in build.log.

Placing a Custom Sample in the Build Tree for Compiling

Most monolithic drivers are coded using a template scheme. This entails selecting the driver which most closely resembles the target device type. Switching into its $HOME directory and cleaving the source for your driver into a new subdirectory under it. Then make your changes and test them. Say you are using the text-only sample driver as your template.

Create and switch to c:\ddk\src\print\newdrv

Type cd newdrv

Type xcopy \ddk\src\print\textonly\*.* ..\newdrv /s

To build, simply type bld. Note: You may need to run BLD from psprint first.

Logs are in build.log and build.wrn.

Output .dll products are in c:\ddk\lib\i386 unless otherwise noted in build.log.

The dirs file specifies which directories in the subtrees contain source-code files which are to be built. The sources file specifies which source files are required to build the current driver.

If your driver will consist of multiple binaries, or the source will be kept in multiple directories, you may need to create a dirs file specifying which directories are to be built and in what order. Each separate binary will require a sources file describing which files are to be compiled/linked to create the driver.

Building a Device Driver Installation Diskette

The Windows 2000 printer device driver installation diskette includes the following files: OEMSETUP.INF, DRVUI.DLL, DRV.DLL, DISK1 DRV.HLP. The creation of a disk with these items on it will constitute a driver installation disk which will install as part of the Windows phase of setup (after the original install of Windows 2000).

Resources

Device Driver Development URLs

The sites listed below are an excellent resource for device driver development, debugging, and testing.

  • http://www.microsoft.com/hwdev (For hardware developers only.)

  • http://www.microsoft.com/support/products/developer/ddk_hardware/ (For device driver writers only.)

  • E-mail ntwish@microsoft.com with product suggestions.

    Newsgroups at msnews.microsoft.com include:

  • microsoft.public.win32.programmer.kernel (Microsoft Windows 95 and Microsoft Windows NT® driver/kernel programming

  • microsoft.public.win16.programmer.kernel (Legacy Windows driver programming)

  • microsoft.public.usasalesinfo.developer.sdk-ddk (SDK- and DDK-related information.)
  • Other Newsgroups

    comp.os.ms-windows.programmer.nt.kernel-mode (Development of Windows NT kernel-mode drivers.)

    Other competitive device driver developer houses include:

  • http://www.bhs.com (Beverly Hills Software—Windows NT Resource Center)
  • http://www.blackice.sendfax.com (Black Ice Software)
  • http://www.bluewatersystems.com (Blue Water Systems)
  • http://www.chsw.com (Cherry Hill Software)
  • http://www.ntinternals.com (NT Internals)
  • http://www.numega.com (Nu-Mega Technologies)
  • http://www.vireo.com (Vireo software—Driver Wizards)
  • http://www.tetradyne.com (Tetradyne Software)
  • Device Driver Development Books

    [PSC1] Refer to the materials below for additional information regarding device driver development, debugging and testing.

  • Windows NT Workstation Resource Kit, Microsoft Press (ISBN: 1-57231-343-9)
  • Inside Windows NT, by Helen Custer, Microsoft Press (ISBN: 1-55615-481-X)
  • Inside the Windows NT File System, by Helen Custer, Microsoft Press (ISBN: 1-55615-660-X)
  • The Windows Device Driver Book, by Art Baker, Prentice Hall (ISBN: 0-13-184474-1)
  • Windows NT DDK Graphics Device Driver Development/Design Guide and Reference (Windows NT DDK)
  • Advanced Windows NT, by Jeffrey Richter, Microsoft Press (ISBN: 1-55615-567-0)
  • Microsoft Windows NT Server Resource Kit by Microsoft Corporation, 1995 (ISBN: 1-57231-344-7)
  • Microsoft Windows NT Workstation Resource Kit by Microsoft Corporation, 1995 (ISBN:1-57231-343-9)
  • Advanced Windows (with CD-ROM) by Jeffrey M. Richter, 1996 (ISBN:1-57231-548-2)
  • E-Mail Discussion Groups

    The DDK-L e-mail discussion group: Separate areas for Windows 95, Windows NT, network, and file system driver discussions.

    NTDEV—Windows NT device drivers: To subscribe, send "SUBSCRIBE NTDEV" in the body of a message to majordomo@atria.com.

    NTIFS—Windows NT installable file systems: To subscribe, send "SUBSCRIBE NTDEV" in the body of a message to majordomo@atria.com.

    The VCOMM mailing list—Win32 Comm API and Driver Issues: For more information, send "info VCOMM" in the body of a message to majordomo@corp.nsc.com.

    Top of page

    © 1999 Microsoft Corporation