Device Names

To open a device using DosOpen, the application must supply the reserved name for that device. For example, to open the console (both keyboard and screen), you must specify the name CON.

The following table shows some of the common reserved device names:

Common Device Names

┌───────────┬──────────────────────────────────────────────────┐
│Device Name│Description                                       │
├───────────┼──────────────────────────────────────────────────┤
│CON        │The system console. This device consists of both  │
│           │the keyboard and the screen. You can open CON for │
│           │reading (from the keyboard), writing (to the      │
│           │screen), or both.                                 │
├───────────┼──────────────────────────────────────────────────┤
│COM1       │Serial port 1. You can open this device for       │
│           │reading, writing, or both. Other serial ports will│
│           │have names in ascending sequence-COM2, COM3, and  │
│           │so on.                                            │
├───────────┼──────────────────────────────────────────────────┤
│PRN        │The default printer port. This device corresponds │
│           │to one of the system's parallel ports, usually    │
│           │LPT1. You can open it for writing but not for     │
│           │reading.                                          │
├───────────┼──────────────────────────────────────────────────┤
│LPT1       │Parallel port 1. You can open this device for     │
│           │writing but not for reading. Other parallel ports │
│           │will have names in ascending sequence-LPT2, LPT3, │
│           │and so on.                                        │
├───────────┼──────────────────────────────────────────────────┤
│NUL        │The null device. This device provides a method of │
│           │discarding output. If you open this device for    │
│           │writing, any data written to the file is          │
│           │discarded. If you open the device for reading, any│
│           │attempt to read from the file returns an          │
│           │end-of-file mark.                                 │
├───────────┼──────────────────────────────────────────────────┤
│SCREEN$    │The screen. This device can be written to but not │
│           │read from. Writing to the screen is similar to    │
│           │writing to the system console. Bytes are displayed│
│           │as characters (unless the ANSI screen driver is   │
│           │loaded and the character represents an ANSI escape│
│           │sequence).                                        │
├───────────┼──────────────────────────────────────────────────┤
│KBD$       │The keyboard. This device can be read from but not│
│           │written to. Reading from the keyboard is similar  │
│           │to reading from the system console.               │
└───────────┴──────────────────────────────────────────────────┘

After an application uses a device, it should close it by using DosClose.


[Back: Accessing Devices]
[Next: Device Drivers]