コード例 #1
0
 public static void Install(PRINTER_INFO_2 info)
 {
     try
     {
         if (!AddPrinter(null, 2, ref info))
         {
             throw new Win32Exception(Marshal.GetLastWin32Error());
         }
         Spool.Restart();
     }
     catch { throw; }
 }
コード例 #2
0
 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);
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }