Get name/port of current printer

Posted in Devices

Use GetPrinter procedure for getting information about current printer. Don't forget include Printers in uses chapter.

uses Printers;
...
procedure TForm1.Button1Click(Sender: TObject);
var
  MyPrinter, MyDriver, MyPort: array[0..100] of Char;
  DevMode: THandle;
begin
  Printer.GetPrinter(MyPrinter, MyDriver, MyPort, DevMode);
  Label1.Caption:=MyPrinter;
  Label2.Caption:=MyPort;
end;