Base class for installing and removing printer drivers. More...
#include <PrinterInstall.h>
Inherited by CCPDFPrinterInstaller.
Public Member Functions | |
| PrinterInstall (LPCTSTR lpPrinterName, LPCTSTR lpPortName, LPCTSTR lpDriverName, LPCTSTR lpHardwareID, const LPCTSTR *pFiles) | |
| Constructor with installation data. | |
| PrinterInstall () | |
| Default constructor. | |
| int | GetError () const |
| Retrieves the last error number. | |
| int | GetLastError () const |
| Retrieves the last error description. | |
| void | InitializePrinterData (LPCTSTR lpPrinterName, LPCTSTR lpPortName, LPCTSTR lpDriverName, LPCTSTR lpHardwareID, const LPCTSTR *pFiles) |
| Initializes the printer driver data. | |
| int | Install (LPCTSTR lpFilesPath, HWND hParent) |
| Install the printer driver. | |
| int | Uninstall (HWND hParent) |
| Remove the printer driver. | |
| bool | DoCommandLine (int nArgs, TCHAR **pArgs, bool &bNoUI, LPCTSTR lpRelativeDriverFolder) |
| Installs or removes the printer driver according to the command line parameters. | |
| bool | AddPortMonitor (LPCTSTR lpMonitorName, LPCTSTR lpMonitorFile, LPCTSTR lpFilePath) |
| Add a port monitor. | |
| bool | RemovePortMonitor (LPCTSTR lpMonitorName) |
| Remove a port monitor. | |
| bool | IsPrinterInstalled (bool &bInstalled) |
| Tests if the printer is installed. | |
Protected Member Functions | |
| bool | DoAddPort () |
| Add a printer port to windows. | |
| bool | DoDeletePort (HWND hWnd) |
| Remove a printer port from windows. | |
| bool | DoCopyFiles (LPCTSTR lpCopyFrom) |
| Copy driver files from a folder to the windows printer drivers folder. | |
| bool | DoRemoveFiles () |
| Remove the printer driver files from the windows folder. | |
| bool | DoInstallPrinterDriver () |
| Install the printer driver. | |
| bool | DoUninstallPrinterDriver () |
| Remove the printer driver. | |
| bool | DoAddPrinter () |
| Add a printer. | |
| bool | DoRemovePrinter (LPTSTR lpName) |
| Remove the printer. | |
| bool | DoRemovePrinters () |
| Remove all the printers for this driver. | |
| void | SetError (int nError) |
| Set an error. | |
| void | ResetError () |
| Reset the error members. | |
Protected Attributes | |
| std::tstring | m_sPrinterName |
| Printer name. | |
| std::tstring | m_sPortName |
| Printer port name. | |
| std::tstring | m_sDriverName |
| Printer driver name. | |
| std::tstring | m_sHardwareID |
| Hardware ID (should be unique to the driver). | |
| std::tstring | m_sPortMonitor |
| Port monitor name. | |
| STRARRAY | m_arFiles |
| Array of files to install. | |
| int | m_nError |
| Last error number. | |
| int | m_nLastError |
| Last error description. | |
| bool | m_bLockError |
| Flag to keep the previous error number and message. | |
Base class for installing and removing printer drivers.
Definition at line 51 of file PrinterInstall.h.
| PrinterInstall::PrinterInstall | ( | LPCTSTR | lpPrinterName, | |
| LPCTSTR | lpPortName, | |||
| LPCTSTR | lpDriverName, | |||
| LPCTSTR | lpHardwareID, | |||
| const LPCTSTR * | pFiles | |||
| ) |
Constructor with installation data.
| lpPrinterName | Name of printer to install | |
| lpPortName | Name of port to create | |
| lpDriverName | Name of printer driver | |
| lpHardwareID | Unique hardware ID for the printer | |
| pFiles | Pointer to array of files to install |
Definition at line 160 of file PrinterInstall.cpp.
References m_arFiles.
| bool PrinterInstall::AddPortMonitor | ( | LPCTSTR | lpMonitorName, | |
| LPCTSTR | lpMonitorFile, | |||
| LPCTSTR | lpFilePath | |||
| ) |
Add a port monitor.
| lpMonitorName | Name of port monitor | |
| lpMonitorFile | Port monitor DLL filename | |
| lpFilePath | Path where the port monitor file currently resides |
Definition at line 806 of file PrinterInstall.cpp.
References ConcatPaths(), ENVIRONMENT, ExistsAsFile(), GetLastError(), m_sPortMonitor, SetError(), and tstring.
Referenced by CCPDFPrinterInstaller::DoInstall().
| bool PrinterInstall::DoAddPort | ( | ) | [protected] |
Add a printer port to windows.
Definition at line 221 of file PrinterInstall.cpp.
References GetLastError(), m_sPortMonitor, m_sPortName, MakeWideString(), SetError(), and tstring.
Referenced by Install().
| bool PrinterInstall::DoAddPrinter | ( | ) | [protected] |
Add a printer.
Definition at line 480 of file PrinterInstall.cpp.
References GetLastError(), m_sDriverName, m_sPortName, m_sPrinterName, PRINTER_DATA_TYPE, and SetError().
Referenced by Install().
| bool PrinterInstall::DoCommandLine | ( | int | nArgs, | |
| TCHAR ** | pArgs, | |||
| bool & | bNoUI, | |||
| LPCTSTR | lpRelativeDriverFolder | |||
| ) |
Installs or removes the printer driver according to the command line parameters.
| nArgs | Number of command line arguments | |
| pArgs | Pointer to an array of command line arguments | |
| bNoUI | Reference to a silent command flag, filled upon exit | |
| lpRelativeDriverFolder | Folder name (relative to the current module) where the printer driver files can be found |
Command line usage: To install the printer: <app.exe> [/NoUI] /InstallPrinter To uninstall the printer: <app.exe> [/NoUI] /UninstallPrinter Note that the object must be initialized for this to work!
Definition at line 750 of file PrinterInstall.cpp.
References Install(), PARAM_INSTALLPRINTER, PARAM_NOUI, PARAM_REMOVEPRINTER, ResetError(), SetError(), and Uninstall().
| bool PrinterInstall::DoCopyFiles | ( | LPCTSTR | lpCopyFrom | ) | [protected] |
Copy driver files from a folder to the windows printer drivers folder.
| lpCopyFrom | Folder to copy the printer driver files from |
Definition at line 281 of file PrinterInstall.cpp.
References ConcatPaths(), GetLastError(), m_arFiles, SetError(), and tstring.
Referenced by Install().
| bool PrinterInstall::DoDeletePort | ( | HWND | hWnd | ) | [protected] |
Remove a printer port from windows.
| hWnd | Handle to the parent window |
Definition at line 261 of file PrinterInstall.cpp.
References GetLastError(), m_sPortName, and MakeWideString().
Referenced by Install(), and Uninstall().
| bool PrinterInstall::DoInstallPrinterDriver | ( | ) | [protected] |
Install the printer driver.
Definition at line 365 of file PrinterInstall.cpp.
References DATA_FILE_NUM, DRIVER_DATA_TYPE, DRIVER_FILE_NUM, DRIVER_MANUFACTURER, ENVIRONMENT, GetLastError(), HELP_FILE_NUM, m_arFiles, m_sDriverName, m_sHardwareID, SetError(), and UI_FILE_NUM.
Referenced by Install().
| bool PrinterInstall::DoRemoveFiles | ( | ) | [protected] |
Remove the printer driver files from the windows folder.
Definition at line 329 of file PrinterInstall.cpp.
References ConcatPaths(), GetLastError(), m_arFiles, SetError(), and tstring.
Referenced by Install().
| bool PrinterInstall::DoRemovePrinter | ( | LPTSTR | lpName | ) | [protected] |
Remove the printer.
| lpName | Name of printer to delete |
Definition at line 515 of file PrinterInstall.cpp.
References GetLastError(), and SetError().
Referenced by DoRemovePrinters().
| bool PrinterInstall::DoRemovePrinters | ( | ) | [protected] |
Remove all the printers for this driver.
Definition at line 594 of file PrinterInstall.cpp.
References DoRemovePrinter(), m_sDriverName, and SetError().
Referenced by Uninstall().
| bool PrinterInstall::DoUninstallPrinterDriver | ( | ) | [protected] |
Remove the printer driver.
Definition at line 457 of file PrinterInstall.cpp.
References ENVIRONMENT, GetLastError(), m_sDriverName, and SetError().
Referenced by Install(), and Uninstall().
| int PrinterInstall::GetError | ( | ) | const [inline] |
Retrieves the last error number.
Definition at line 90 of file PrinterInstall.h.
References m_nError.
Referenced by CCPDFPrinterInstaller::DoInstall(), and CCPDFPrinterInstaller::DoRemove().
| int PrinterInstall::GetLastError | ( | ) | const [inline] |
Retrieves the last error description.
Definition at line 95 of file PrinterInstall.h.
References m_nLastError.
Referenced by AddPortMonitor(), DoAddPort(), DoAddPrinter(), DoCopyFiles(), DoDeletePort(), CCPDFPrinterInstaller::DoInstall(), DoInstallPrinterDriver(), CCPDFPrinterInstaller::DoRemove(), DoRemoveFiles(), DoRemovePrinter(), DoUninstallPrinterDriver(), RemovePortMonitor(), and SetError().
| void PrinterInstall::InitializePrinterData | ( | LPCTSTR | lpPrinterName, | |
| LPCTSTR | lpPortName, | |||
| LPCTSTR | lpDriverName, | |||
| LPCTSTR | lpHardwareID, | |||
| const LPCTSTR * | pFiles | |||
| ) |
Initializes the printer driver data.
| lpPrinterName | Name of printer to install | |
| lpPortName | Name of port to create | |
| lpDriverName | Name of printer driver | |
| lpHardwareID | Unique hardware ID for the printer | |
| pFiles | Pointer to array of files to install |
Definition at line 184 of file PrinterInstall.cpp.
References m_arFiles, m_sDriverName, m_sHardwareID, m_sPortName, and m_sPrinterName.
| int PrinterInstall::Install | ( | LPCTSTR | lpFilesPath, | |
| HWND | hParent | |||
| ) |
Install the printer driver.
| lpFilesPath | Path of printer driver files | |
| hParent | Handle to parent window |
Definition at line 642 of file PrinterInstall.cpp.
References DoAddPort(), DoAddPrinter(), DoCopyFiles(), DoDeletePort(), DoInstallPrinterDriver(), DoRemoveFiles(), DoUninstallPrinterDriver(), m_nError, m_sPrinterName, ResetError(), and SetError().
Referenced by DoCommandLine(), and CCPDFPrinterInstaller::DoInstall().
| bool PrinterInstall::IsPrinterInstalled | ( | bool & | bInstalled | ) |
Tests if the printer is installed.
| bInstalled | Reference to the installed flag, filled upon return |
Definition at line 554 of file PrinterInstall.cpp.
References m_sDriverName, and SetError().
Referenced by CCPDFPrinterInstaller::IsPrinterInstalled().
| bool PrinterInstall::RemovePortMonitor | ( | LPCTSTR | lpMonitorName | ) |
Remove a port monitor.
| lpMonitorName | Name of port monitor |
Definition at line 896 of file PrinterInstall.cpp.
References ENVIRONMENT, GetLastError(), and SetError().
Referenced by CCPDFPrinterInstaller::DoInstall(), and CCPDFPrinterInstaller::DoRemove().
| void PrinterInstall::SetError | ( | int | nError | ) | [protected] |
Set an error.
| nError | The error to set |
Definition at line 204 of file PrinterInstall.cpp.
References GetLastError(), m_bLockError, m_nError, and m_nLastError.
Referenced by AddPortMonitor(), DoAddPort(), DoAddPrinter(), DoCommandLine(), DoCopyFiles(), DoInstallPrinterDriver(), DoRemoveFiles(), DoRemovePrinter(), DoRemovePrinters(), DoUninstallPrinterDriver(), Install(), IsPrinterInstalled(), RemovePortMonitor(), and Uninstall().
| int PrinterInstall::Uninstall | ( | HWND | hParent | ) |
Remove the printer driver.
| hParent | Handle to the parent window |
Definition at line 697 of file PrinterInstall.cpp.
References DoDeletePort(), DoRemovePrinters(), DoUninstallPrinterDriver(), m_nError, m_sPrinterName, ResetError(), and SetError().
Referenced by DoCommandLine(), CCPDFPrinterInstaller::DoInstall(), and CCPDFPrinterInstaller::DoRemove().
1.6.1