Delphi programming to detect the existence of printers

Source: Internet
Author: User

Printers is designed to control the printer, but when the printer is not installed, but will be prompted I/O error, so there must be a test to detect the existence of a printer, I tried many methods, but I/O error is always earlier than my judgment, so use the following bad recruit to detect the printer. You can detect the presence of a printer by first adding printers to the uses, then preparing a list box ComboBox1, its properties visible set to False, and then executing the following statements before printing:

procedure TForm1.ButtonClick(Sender: TObject);
begin
ComboBox1.Clear;
ComboBox1.Items.Assign(Printer.Printers);
if ComboBox1.Items.CommaText= then
Messagedlg(你需要安装打印机才能打印!,mtError,[mbOk],0);
else
Form1.Print;
end;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.