Taking the name of the Standard Printer

Asked

Viewed 483 times

2

I can get the default printer name declared Printers in the uses section:

Printer.Printers[Printer.PrinterIndex]

If by chance, while running the program the user changes the default printer. How do I get this new printer(printer name)?

  • I would try to use an event

  • It would just be run every time Printer.Printers[Printer.PrinterIndex] that you need, unless a Delphi application saves the printers in some kind of memory cache. But I don’t understand much of the technology.

  • @Guilhermenascimento, does not work, if I call the Printer.Printers[Printer.Printerindex] method will bring up the default printer, now if I change the default printer without closing my application and calling again the Printer.Printers[Printer.Index printers] method will continue to bring the first standard printer, now if you restart the program, and call the method dai updates the default printer.

  • But you execute in one piece Printer.Printers[Printer.PrinterIndex] or just takes the variable that received the value of the item of this specific index?

  • @Guilhermenascimento executed whole.

1 answer

3


There is a procedure in the Set of the Printerindex property, when you pass the value -1 it will always return the default windows printer. Ex:

if Printer.Printers.Count > 0 then
begin
  Printer.PrinterIndex := -1;
  ShowMessage(Printer.Printers[Printer.PrinterIndex]);
end;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.