## The WORKITEM Sample

The WORKITEM Sample accompanies Chapter 14 and illustrates how to use IoQueueWorkItem and related routines to queue a work item. This sample was revised for SP-2 in the 1st edition.

The sample includes two components:

- WORKITEM.SYS (SYS subdirectory) is a WDM driver for a non-existent hardware device.
- TEST.EXE (TEST subdirectory) is a Win32 console program that tests WORKITEM.SYS.

### Building WORKITEM

To build WORKITEM.SYS, follow the general instructions for building a WDM sample. The Microsoft Visual C++ project file is named WORKITEM.DSP.

To build TEST.EXE, follow the general instructions for building user-mode programs. The Microsoft Visual C++ project file is named TEST.DSP in the TEST subdirectory.

### Testing WORKITEM

First install the WORKITEM.SYS driver. Follow the general instructions for using FastInst in Windows XP or Windows 98/Me. The INF file is named SYS\WORKITEM.INF.

Open a command prompt and execute TEST.EXE from the TEST\DEBUG subdirectory. TEST will call WORKITEM to queue a work item that should complete almost immediately and report back to TEST. TEST prints a message to indicate the results.

### What to look for

The handler for IOCTL_SUBMIT_ITEM (Control.cpp) illustrates how to queue a work item. The callback routine, WorkItemCallback is also located in Control.cpp.