The CPrinterConfig class provides a way to identify a printer and create a device context for it using a particular configuration. The Windows API also provides functions for directly accessing printers and the print spooler. The Windows API function OpenPrinter() returns a handle for a printer that can be used in conjunction with several other functions such as ReadPrinter(), WritePrinter(), GetJob(), PrinterProperties(), and DeletePrinter(). The CPrinter class encapsulates a printer handle and the Windows API functions for accessing printers and the printer spooler.
The CPrinter class implements an Open() method, which takes the name of a printer and calls the OpenPrinter() Windows API function in order to get back a valid printer handle. The CPrinter class also has the Attach() and Detach() methods for assigning an existing printer handle to a printer object. The remaining methods in this class are simple wrappers for Windows API functions that operate on a printer handle.