Is there a .NET way to enumerate all available network printers?

后端 未结 6 664
悲&欢浪女
悲&欢浪女 2020-11-28 09:16

Is there a straightforward way to enumerate all visible network printers in .NET? Currently, I\'m showing the PrintDialog to allow the user to select a printer. The problem

6条回答
  •  失恋的感觉
    2020-11-28 09:40

    using the new System.Printing API

    using (var printServer = new PrintServer(string.Format(@"\\{0}", PrinterServerName)))
    {
        foreach (var queue in printServer.GetPrintQueues())
        {
            if (!queue.IsShared)
            {
                continue;
            }
            Debug.WriteLine(queue.Name);
         }
     }
    

提交回复
热议问题