4

Given a connection to a terminal server, when using a test program written in Delphi XE2, the list of printer names in the Printer.Printers collection is different from the list of printers shown when using a TPrintDialog.

Some of the redirected printers show up in both, but the print dialog contains 3 more local printers that have been redirected.

I've tried looking at the code in Vcl.Dialogs to see where the print dialog is getting its list of printers but no joy there.

I've also tried calling EnumPrinters directly but I get the same result, not unsurprisingly.

How can I be sure that I can get the same list of printers - local/network/redirected - within my Delphi code as I see if I look at the Printers via Control Panel?

SiBrit
  • 1,460
  • 12
  • 39
  • Possibly related: http://stackoverflow.com/questions/2601037/list-local-printers and http://stackoverflow.com/questions/23301795/delphi-2007-not-all-installed-printers-show-in-printer-setup-dialog – Jan Doggen Sep 21 '14 at 21:13
  • 1
    That's system dialog, there is no source for it. I suggest you to attract `[winapi]` clientele by reasking about `EnumPrinters` or editing tags. As far as I remember, there are lot of woes with whole printer redirection thing. – Free Consulting Sep 22 '14 at 01:42
  • Have you tried calling 'Printer.Refresh' just before getting the list of printers? – Copilot Sep 22 '14 at 05:47
  • It certainly seems related to the Easy Print services included in Server 2008 and onwards, in that TS would try to install a redirected printer driver using EP, and if that failed, look for a locally installed driver. If it couldn't find one of those either it would not include that local printer. However, that does not explain how some methods for getting the list of printers give different results. – SiBrit Sep 28 '14 at 20:26
  • @Jan I used a variation of the code from 2601037 to get the list of printers (although XE2 does not have a _PRINTER_INFO_2A, just a _PRINTER_INFO_2). Calling EnumPrinters and getting the result is fine. What is wrong is the returned list of printers is incorrect. As for 23301795, the program is started as a RemoteApp and they have not installed any new local printers for a while. – SiBrit Sep 29 '14 at 02:35
  • @Free I've added the winapi tag to see if anyone else has an answer, especially since EnumPrinters actually has 8 different versions of PRINTER_INFO now. – SiBrit Sep 29 '14 at 02:36
  • @Copilot I had them reboot the host last week, just in case. No change. It might have been that TS isn't finished redirecting printers before the RemoteApp starts, but I also had them run it when logged in directly to the host. Same result. Took a look at Vcl.Printers and all Refresh does it clear the FPrinters collection. – SiBrit Sep 29 '14 at 02:49
  • @Sibrit, did you already found a solution for this issue? I am encountering the same issue. Thank you! – davepaul12 Nov 15 '22 at 11:27
  • @davepaul12. Unfortunately not. We ended up having to faff about with the printer names stored locally, and changing the current printer index. – SiBrit Nov 15 '22 at 20:06

0 Answers0