Programming Question

I'm taking my first programming class and I have some questions. How does your program access external devices like a printer or modem? I know in linux everything has a corresponding file but I have no idea how it works in dos/windows.

In general, your application program communicates with a driver, which is a piece of software that knows how to talk directly to the hardware. The driver generally communicates with hardware by reading and writing to various addresses. These addresses are not associated with memory, but instead with some of the various chips inside the computer. Some of the chips do serial communication; others do parallel, others do USB, and so on. When you read and write to those addresses, you are moving data between the processor and those chips, which then communicate with the printer or modem.