Taking the name of the Default Printer

2

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

Printer.Printers[Printer.PrinterIndex]

If by chance, during the execution of the program the user changes the default printer. How can I get this new printer (printer name)?

    
asked by anonymous 31.08.2018 / 19:09

1 answer

3

There is a handle on the Set of the PrinterIndex property, when it passes the -1 value 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;
    
03.09.2018 / 14:58