Share via


Device File Names

Applications can access peripheral devices through file system functions, such as CreateFile. The file system code includes code that recognizes file names such as COM1:, PGR7, and so on. The file I/O operations are redirected to the stream interface.

The following information helps you create file name formats, prefixes, and indexes for devices that have drivers that expose the stream interface.

Device File Name Format

For the file system to recognize file names as devices that expose the stream interface, the file names must consist of three uppercase letters, a single digit, and a colon (:). This format follows the convention established in Microsoft® MS-DOS® for serial and parallel ports. For example, COM1:, PGR7:, and GPS0: are valid device file names, but MODEM1:, COM27:, and LPT1 are not.

Device File Name Prefixes

If the Prefix subkey does not exist, then there must be initialization and de-initialization entry points. Otherwise, the prefix consists of three uppercase letters that identify which device file name corresponds to a particular stream interface. The prefix is stored in a registry value called Prefix, which is located within the key for the driver. Typically, the setup utility that installs a driver creates this registry value, along with the other values that the driver needs.

When you implement the stream interface, you designate the three-letter prefix. It can be any three letters, although you should use a common prefix if your driver is the same class of device as other drivers already present on the platform. For example, drivers for serial devices, such as modems, could use the common prefix COM, even though other drivers might already be using that prefix. Your driver can distinguish itself from other drivers by using a different index.

First, the prefix identifies all possible device file names that can access the stream interface driver. Second, the prefix tells the operating system what entry-point file names to expect in the stream interface dynamic-link library (DLL). For example, to implement a device driver for a PC Card pager, you could choose PGR as the three-letter prefix, which in turn would dictate entry-point names, such as PGR_Init, PGR_IOControl, and so on.

Device File Name Indexes

The index differentiates similar devices that the stream interface manages. The index is the digit that follows the prefix. By default, the Device Manager indexes logically from 1 through 9, with 1 corresponding to the first device file name. If you require a tenth device file name, use 0 as the index.

If you need to number your device file names starting at an index other than 1, specify a starting index in a registry value called Index within the registry key for your driver. This is often necessary if your stream interface driver serves a device that should use a common prefix, such as COM. For example, on many platforms, COM1:, COM2:, and COM3: correspond to built-in serial port hardware. If your driver is for a serial device, such as a packet-radio modem, it should appear as a COM port because modem software often assumes that modems are connected to COM ports. You could specify an Index value of 4 to differentiate your serial device from ones that are built into the hardware.

If you specify Index, rather than letting the Device Manager assign indexes, by default, your driver will support only one device because the Device Manager can register only one device file name. If you need to specify Index but need more than one device file name, you have two options. The initialization function can register additional device file names with the ActivateDeviceEx function, or the setup utility can create additional sets of registry keys, each with a different index, when your driver is installed.

See Also

Stream Interface Drivers

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.