菜鸟提问:
    如何判断本机是否安装有打印机。
    谢谢

解决方案 »

  1.   

    首先在uses增加Printers,然后判断PRINTER.PRINTERS.COUNT是否大于0
      

  2.   

    to Kevin_Lmx(繁华阅尽):谢谢。
    以下这段是我在别处看的,但不知为何通不过,请指教。procedure GetDefaultPrinter;
    begin
      try
        Printer.Refresh;
        if Printer.Printers.Count=0 then
          raise Exception.Create('系统没有安装打印机!');    Printer.PrinterIndex:=-1;//始终使用默认打印机
        if not GetPrinter(Printer.Handle,0,nil,0,nil) then
          raise Exception.Create('打印机没有准备好,可能没有打开电源,'+#13+#13+
                     '或者没有登录到网络打印机所在服务器。');
        //不加上这句,则在安装了打印机但没有连接时,系统将崩溃!
      except
        raise;
      end;
    end;
      

  3.   

    implementation
    uses 
      printers,winspool;
    getprinter函数在winspool单元声明
      

  4.   

    经  XuDunYu(西门吹雪)  指点,程序可通过,但点“打印”之后,系统仍然在这一段报错。
        不知何故,继续请教。谢谢。