如何使用LocalPrintServer定位特定打印机?

| 提出以下问题:如何从打印机队列中检索作业列表或数量? 我仍然停留在如何使用特定打印机的目标上,我目前仅使用LocalPrintServer类知道其名称。该应用程序应该一次打印到多台机器,并且所有打印后台处理程序都需要分别进行监视。谁能为我提供一个代码片段,该代码片段显示如何仅使用打印机名称实例化LocalPrintServer对象? 提前致谢! 编辑:添加了解决方案的代码片段:
private int GetNumberOfPrintJobs()
{
    LocalPrintServer server = new LocalPrintServer();
    PrintQueueCollection queueCollection = server.GetPrintQueues();
    PrintQueue printQueue = null;

    foreach (PrintQueue pq in queueCollection)
    {
        if (pq.FullName == PrinterName) //PrinterName is a classmember
            printQueue = pq;
    }

    int numberOfJobs = 0;
    if (printQueue != null)
        numberOfJobs = printQueue.NumberOfJobs;

    return numberOfJobs;
}
毕竟这并不难!     
已邀请:
尝试指定打印机名称的LocalPrintServer.GetPrintQueue。     
重要说明:从用户的角度来看,“ 1”并不会返回所有已安装的打印机-只会返回本地服务器“拥有”的那些打印机。 更奇怪的是,即使
LocalPrintServer.DefaultPrintQueue
来自from4ѭ对象,也不一定包含在
GetPrintQueues()
中。 如果使用ѭ5(ѭ6),则会从用户角度获得已安装的所有打印机的列表。 如果您已经安装了远程打印机(在打印服务器上),则其中一些可能在远程计算机上。如果它是可通过IP访问的网络打印机,那么它将仍然是本地打印机:
\"Send To OneNote 2010\"  
\"Microsoft XPS Document Writer\" 
\"HP LaserJet P2050 Series PCL6\" 
\"HP LaserJet 1020\"  
\"Fax\"   
\"\\\\\\\\ike\\\\LUCY\" 
\"\\\\\\\\shipping\\\\HP LaserJet 1020\"    
要在远程服务器上检索打印队列,您需要执行以下操作:
new PrintServer(\"\\\\ike\").GetPrintQueue(\"LUCY\")
是的,您需要自己解析。     

要回复问题请先登录注册