加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

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

发布时间:2020-12-15 09:06:32 所属栏目:大数据 来源:网络整理
导读:我的程序是用Delphi编写的(面向对象的pascal).当我尝试打印任何内容时,我收到消息“当前没有选择默认打印机”.在未安装打印机的计算机上. 为了防止这种情况,我想检查是否安装了任何打印机.有没有办法检查是否安装了任何打印机? 解决方法 use Printers; Prin
我的程序是用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,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. }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读