uses printersprocedure 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;
begin
ComboBox1.Clear;
ComboBox1.Items.Assign(Printer.Printers);
if ComboBox1.Items.CommaText=``then Messagedlg(`你需要安装打印机才能打印!`,mtError,[mbOk],0);
else Form1.Print;
end;
asm
MOV DX,$379;
IN AL,DX;
end;
//获取打印机是否出错
function CheckPrinter:boolean;
var
temp:byte;
begin
temp:=GetPrinterStatus;
Result:=not ( ((temp and $80)=0) //打印机忙
or ((temp and $20)<>0) //打印机缺纸
or ((temp and $10)=0) //打印机未联机
or ((temp and $08)=0) ); //打印机出错;
end;