当前位置 : 主页 > 编程语言 > delphi >

如何找到是否安装了打印机(使用Delphi)

来源:互联网 收集:自由互联 发布时间:2021-06-23
我的程序是用Delphi编写的(面向对象的pascal).当我尝试打印任何内容时,我收到消息“当前没有选择默认打印机”.在未安装打印机的计算机上. 为了防止这种情况,我想检查是否安装了任何
我的程序是用Delphi编写的(面向对象的pascal).当我尝试打印任何内容时,我收到消息“当前没有选择默认打印机”.在未安装打印机的计算机上.

为了防止这种情况,我想检查是否安装了任何打印机.有没有办法检查是否安装了任何打印机?

use Printers;

Printer.Printers.Count为您提供安装的打印机数量

这些评论来自D2007中的打印机单元:

{ TPrinter }

  { The printer object encapsulates the printer interface of Windows.  A print
    job is started whenever any redering is done either through a Text variable
    or the printers canvas.  This job will stay open until EndDoc is called or
    the Text variable is closed.  The title displayed in the Print Manager (and
    on network header pages) is determined by the Title property.

    EndDoc - Terminates the print job (and closes the currently open Text).
      The print job will being printing on the printer after a call to EndDoc.
    NewPage - Starts a new page and increments the PageNumber property.  The
      pen position of the Canvas is put back at (0, 0).
    Canvas - Represents the surface of the currently printing page.  Note that
      some printer do not support drawing pictures and the Draw, StretchDraw,
      and CopyRect methods might fail.
    Fonts - The list of fonts supported by the printer.  Note that TrueType
      fonts appear in this list even if the font is not supported natively on
      the printer since GDI can render them accurately for the printer.
    PageHeight - The height, in pixels, of the page.
    PageWidth - The width, in pixels, of the page.
    PageNumber - The current page number being printed.  This is incremented
      when ever the NewPage method is called.  (Note: This property can also be
      incremented when a Text variable is written, a CR is encounted on the
      last line of the page).
    PrinterIndex - Specifies which printer in the TPrinters list that is
      currently selected for printing.  Setting this property to -1 will cause
      the default printer to be selected.  If this value is changed EndDoc is
      called automatically.
    Printers - A list of the printers installed in Windows.
    Title - The title used by Windows in the Print Manager and for network
      title pages. }
网友评论