delphi編程實現檢測存在印表機

來源:互聯網
上載者:User

Printers是專門用來控制印表機的,可是在沒有安裝印表機時,卻會提示I/O錯誤,所以必須有一個檢測是否存在印表機的方法,我試過很多方法,可是I/O錯誤總是比我的判斷早出現,所以採用以下的爛招來檢測印表機。首先在uses增加Printers,再準備一個列表框ComboBox1,其屬性Visible設為FALSE,然後在列印之前執行下列語句,那麼就可以檢測到是否存在印表機了:

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;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.