2

我正在尝试使用 C#.NET Visual Studio 2008 暂停 Windows 7 打印队列。我拥有完整的管理员权限,但是当我运行以下代码暂停队列时,它显示访问被拒绝。请帮我。

        LocalPrintServer lps = new LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer);
        //PrintServer lps = new PrintServer("\\\\NOTEBOOK-CI3", PrintSystemDesiredAccess.AdministratePrinter);
        lps.Commit();
        PrintQueue queue = lps.GetPrintQueue(listBox1.SelectedItem.ToString());
        if (!queue.IsPaused)
            queue.Pause();

        queue.Commit();
        lps.Commit();
4

3 回答 3

5

我有同样的问题,所以对我来说这是最好的解决方案:

PrintS = new PrintServer();
PrintQ = new PrintQueue(PrintS, PrinterName, PrintSystemDesiredAccess.AdministratePrinter);
PrintQ.Pause();

使用本地 PDF 打印机测试

于 2013-06-03T13:17:02.360 回答
1

我不确定,但您是否尝试更改LocalPrinterServerPrinterServer?看看http://www.visualbasicask.com/visual-basic-language/printqueuepause.shtml
他有完全相同的问题,并且可以通过使用 PrintSystemDesiredAccess.AdministrateServer(您确实使用)来解决它。唯一的区别是您使用LocalPrinterServer的是PrinterServer.

于 2010-10-02T15:29:15.730 回答
0

Are you running your website as 4.0? I ran into issues when we upgraded our website from 3.5 to 4.0 Framework. The Print Purging functionality stopped working in the 4.0 Framework. Ultimately I ended up creating a web service that used the 3.5 framework and had the 4.0 website communicate the printer it wanted to purge to the 3.5 web service.

(Sorry to revive this thread, this was one of the threads I stumbled onto when I was looking for an answer. Figured I'd post this if it helps someone that runs into the same situation)

于 2016-02-04T16:27:04.540 回答