CPrinter Class

class CPrinter

This class encapsulates a Windows printer. It is basically a wrapper class that provides easy access to the printer API functions. The class can be passed an existing printer handle or it can create one by opening a specified printer. This class can be used in conjunction with the CPrinterConfig class to open a printer. It is also used in conjunction with the CPrintJob class. Using this class you can get a list of print jobs currently spooled to a printer. You can also reset the printer or even delete the printer.

Defined in: Printer.h

Class Members

CPrinter(HANDLE hPrinter = NULL, const bool bOwnHandle = true) : (HANDLE hPrinter = NULL, const bool bOwnHandle = true)

Construct a printer from a handle.

virtual ~CPrinter()

Destroy printer object.

HANDLE m_hPrinter

Handle to printer.

PRINTER_DEFAULTS m_printerDefaults

API structure passed to OpenPrinter to specify desired access level to printer.

bool m_bOwnHandle

Flag to determine if this object will close the printer when destroyed.

operator HANDLE()

Return the printer handle associated with this object.

virtual void Attach(HANDLE hPrinter, bool bOwnHandle = true)

Attach an existing printer handle to this object.

virtual HANDLE Detach()

Detach the handle associated with this object.

bool Open(LPCTSTR pPrinterName)

Open a printer by device name.

bool IsOpen() const

Determines if this object is associated with an open printer handle.

bool Close()

Close the printer handle associated with this object.

bool Delete()

Delete the printer configuration associated with this object.