gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 15:47:19 24 4
gpt4 key购买 nike

我的程序是用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. }

关于delphi - 如何查找是否安装了打印机(使用Delphi),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2993576/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com