public static void Install(PRINTER_INFO_2 info) { try { if (!AddPrinter(null, 2, ref info)) { throw new Win32Exception(Marshal.GetLastWin32Error()); } Spool.Restart(); } catch { throw; } }
public static ActionResult RestartSpoolService(Session session) { session.Log("Custom action RestartSpoolService - Start"); try { Spool.Restart(); } catch (Exception ex) { session.Log("Custom action RestartSpoolService - Exception: " + ex.Message); session.Log("Custom action RestartSpoolService - Exit (Failure)"); } session.Log("Custom action RestartSpoolService - Exit (Success)"); return(ActionResult.Success); }
public static ActionResult InstallSmartPrint(Session session) { session.Log("Custom action InstallPrinter - Start"); try { PrintDriver.Install(); PrintMonitor.Install(); Spool.Restart(); } catch (Exception ex) { session.Log("Custom action InstallPrinter - Exception: " + ex.Message); session.Log("Custom action InstallPrinter - Exit (Failure)"); return(ActionResult.Failure); } session.Log("Custom action InstallPrinter - Exit (Success)"); return(ActionResult.Success); }
public static ActionResult UninstallSmartPrint(Session session) { session.Log("Custom action UninstallPrinter - Start"); try { // TODO: Find all SmartPrintDevices installed locally and delete them // Deleting PrintMonitor will remove all ports of that PrintMonitor type PrintMonitor.Uninstall(); PrintDriver.Uninstall(); Spool.Restart(); } catch (Exception ex) { session.Log("Custom action UninstallPrinter - Exception: " + ex.Message); session.Log("Custom action UninstallPrinter - Exit (Failure)"); } session.Log("Custom action UninstallPrinter - Exit (Success)"); return(ActionResult.Success); }