如何安装打印机(使用Delphi) [英] How can I find if there are printers installed (using Delphi)
本文介绍了如何安装打印机(使用Delphi)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的程序是用Delphi(面向对象的pascal)编写的。当我尝试打印任何东西时,我收到消息目前没有默认打印机当前选择。在没有安装打印机的计算机上。
My program is written in Delphi (object oriented pascal). When I try to print anything I get the message "There is no default printer currently selected." on computers with no printers installed.
为了防止这种情况,我想检查是否安装了任何打印机。有没有办法检查是否安装了任何打印机?
To prevent this I want to check if there are any printers installed. Is there any way to check if any printers are installed?
推荐答案
use Printers;
Printer.Printers.Count
给你打印机安装数量
D2007中的打印机单元的注释:
The comments form the Printers unit in 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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文