标签: printqueue

访问被拒绝尝试在C#中清除printqueue

我正在尝试在C#中创建一个清空打印队列中所有项目的方法.以下是我的代码:

LocalPrintServer localPrintServer = new LocalPrintServer(PrintSystemDesiredAccess.AdministratePrinter); 
PrintQueue printQueue = localPrintServer.GetPrintQueue(printerName);

if (printQueue.NumberOfJobs > 0)
{
    printQueue.Purge();
}
Run Code Online (Sandbox Code Playgroud)

当此代码运行时,在localPrintServer构造函数上,应用程序抛出此错误:"创建PrintServer对象时发生异常.Win32错误:访问被拒绝."

该构造函数有一些重载(包括不发送参数).尝试其中任何一个,我越过那一行,但是当我进入printQueue.Purge()调用时,我得到了与上面列出的相同的访问被拒绝消息.

寻找有关如何/我可以做些什么的建议来解决这个问题.我可以从我的电脑手动删除打印作业.我不确定应用程序是否以相同的访问权限运行,也不确定如何检查.

c# access-denied printqueue

7
推荐指数
2
解决办法
7919
查看次数

网络打印机和PrintServer.GetPrintQueues方法

我有一种感觉,PrintServer.GetPrintQueues方法 不会返回网络打印机.

如果这个是真的,我还有其他选择吗?

vb.net printing system.printing printqueue

6
推荐指数
1
解决办法
4750
查看次数

System.Printing.PrintQueue QueueStatus 未更新

有没有办法更新包含在PrintQueue对象中的打印队列状态信息?

我试过在PrintQueue对象上调用Refresh,但这并没有真正做任何事情。例如,我已经关闭了打印机,并且控制面板正确地将打印机显示为“离线”,但是QueueStatus属性以及 IsOffline 属性并未反映这一点 - 无论我在两者上调用 Refresh 多少次有问题的PrintServerPrintQueue

我已经看到了如何使用 WMI 查询获取状态信息的示例,但我想知道 - 因为这些属性在PrintQueue对象上可用- 是否有任何方法可以使用这些属性。

printing wpf system.printing printqueue

5
推荐指数
1
解决办法
1914
查看次数

获取共享打印机的打印队列详细信息

正在尝试在共享打印机上打印文档;我需要获取打印队列详细信息。以下代码始终从“Microsoft XPS 文档”获取队列,因为作业数 = 0。但我的默认打印机配置为“HP LaserJet P1505n”

LocalPrintServer server = new LocalPrintServer()
PrintQueueCollection queueCollection = server.GetPrintQueues();
PrintQueue printQueue = null;
foreach (PrintQueue pq in queueCollection)
{
 Logger.LogInfo("PrintQueue1", "Printer1 Queue Name " + pq.FullName);
 printQueue = pq;
 numberOfJobs = printQueue.NumberOfJobs;
 Logger.LogInfo("numberOfJobs1"+ numberOfJobs);
}
Run Code Online (Sandbox Code Playgroud)

如何从该特定共享打印机获取打印队列详细信息?我也试过

PrintServer server = new PrintServer(@"\\192.168.100.168\HP LaserJet P1505n");
Run Code Online (Sandbox Code Playgroud)

但得到错误为:

Win32 错误:文件名、目录名或卷标语法不正确

我在这里缺少什么?

.net c# printing system.printing printqueue

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

printqueue ×4

printing ×3

system.printing ×3

c# ×2

.net ×1

access-denied ×1

vb.net ×1

wpf ×1