home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / lan / netcraft / netprint.pas < prev    next >
Pascal/Delphi Source File  |  1988-06-10  |  4KB  |  192 lines

  1. {*********************************************************************
  2.  
  3.   NETPRINT - A unit of NetWare Application Program Interfaces
  4.              Relating to Network Print Services
  5.              for Turbo Pascal 4.0 and Advanced NetWare (any verison)
  6.  
  7.   Copyright (c) 1988, Richard S. Sadowsky
  8.   All rights reserved
  9.  
  10.   version .7 6/10/88 by Richard S. Sadowsky
  11.  
  12. **********************************************************************}
  13. Unit NetPrint;
  14. {$I-,V-,S+,R+}
  15.  
  16. interface
  17.  
  18. uses DOS;
  19.  
  20. type
  21.   PrinterDevice    = (LPT_1,LPT_2,LPT_3); { enum type to hold LPT number }
  22.  
  23. var
  24.   NovRegs          : Registers; { register type for DOS/Novell calls }
  25.  
  26. function CancelLPTCapture : Word;
  27. { abort capture of default LPT device }
  28.  
  29. function EndLPTCapture : Word;
  30. { end the capture of default LPT device (like ENDSPOOL) }
  31.  
  32. function FlushLPTCapture : Word;
  33. { Flush capture of default LPT device (like running SPOOL again while
  34.   spooling
  35. }
  36.  
  37. function GetDefaultLocalPrinter : PrinterDevice;
  38. { Get LPT device currently used as default by network for capture }
  39.  
  40. procedure SetDefaultLocalPrinter(LPTNo : PrinterDevice);
  41. { Sets LPT device used as default by network for capture }
  42.  
  43. function StartLPTCapture : Word;
  44. { Start Capture of default LPT device (Like running SPOOL) }
  45.  
  46. function LPTCaptureActive(var QueServer : Byte) : Boolean;
  47. { Is spooling occurring now for specified QueServer? }
  48.  
  49. procedure GetPrinterStatus(var PrinterNo,FormType : Byte;
  50.           var OffLine,Stopped : Boolean);
  51. { return assorted information about the default network printer }
  52.  
  53. function GetBannerUser : String;
  54. { returns the user name that is printed on the banner page }
  55.  
  56. implementation
  57.  
  58. function CancelLPTCapture : Word;
  59.  
  60.  
  61. begin
  62.   with NovRegs do begin
  63.     AX := $DF00;
  64.     DX := $02;
  65.     MsDos(NovRegs);
  66.     CancelLPTCapture := AL
  67.   end;
  68. end;
  69.  
  70. function EndLPTCapture : Word;
  71.  
  72. begin
  73.   with NovRegs do begin
  74.     AX := $DF00;
  75.     DX := $01;
  76.     MsDos(NovRegs);
  77.     EndLPTCapture := AL;
  78.   end
  79. end;
  80.  
  81. function FlushLPTCapture : Word;
  82.  
  83. begin
  84.   with NovRegs do begin
  85.     AX := $DF00;
  86.     DX := $03;
  87.     MsDos(NovRegs);
  88.     FlushLPTCapture := AL
  89.   end
  90. end;
  91.  
  92. function GetDefaultLocalPrinter : PrinterDevice;
  93.  
  94. begin
  95.   with NovRegs do begin
  96.     AX := $B800;
  97.     DX := $04;
  98.     MsDos(NovRegs);
  99.     GetDefaultLocalPrinter := PrinterDevice(DH MOD 3) { force in range 0..2 }
  100.   end
  101. end;
  102.  
  103. function StartLPTCapture : Word;
  104.  
  105. begin
  106.   with NovRegs do begin
  107.     AX := $DF00;
  108.     DX := $00;
  109.     MsDos(NovRegs);
  110.     StartLPTCapture := AL
  111.   end
  112. end;
  113.  
  114. function LPTCaptureActive(var QueServer : Byte) : Boolean;
  115.  
  116. begin
  117.   with NovRegs do begin
  118.     AH:= $F0;
  119.     AL := $03;
  120.     MsDos(NovRegs);
  121.     LPTCaptureActive := $FF = AH;
  122.     QueServer := AL;
  123.   end;
  124. end;
  125.  
  126. procedure GetPrinterStatus(var PrinterNo,FormType : Byte;
  127.           var OffLine,Stopped : Boolean);
  128.  
  129. var
  130.   Request          : record
  131.                        BufLen : Word; { 2 }
  132.                        SubF,          { $06 }
  133.                        Num    : Byte;
  134.                      end;
  135.   Reply            : record
  136.                        BufLen : Word; { 4 }
  137.                        Bytes  : Array[1..4] of Byte;
  138.                      end;
  139.  
  140. begin
  141.   with Request do begin
  142.     BufLen := 2;
  143.     SubF   := $06;
  144.     Num    := PrinterNo;
  145.   end;
  146.   Reply.BufLen := 4;
  147.   with NovRegs do begin
  148.     AX := $E000;
  149.     DS := Seg(Request);
  150.     SI := Ofs(Request);
  151.     ES := Seg(Reply);
  152.     DI := Ofs(Reply);
  153.   end;
  154.   MsDos(NovRegs);
  155.   with Reply do begin
  156.     Stopped   := Bytes[1] = $FF;
  157.     OffLine   := Bytes[2] = $01;
  158.     FormType  := Bytes[3];
  159.     PrinterNo := Bytes[4];
  160.   end;
  161. end;
  162.  
  163. procedure SetDefaultLocalPrinter(LPTNo : PrinterDevice);
  164.  
  165. begin
  166.   with NovRegs do begin
  167.     AX := $DF00;
  168.     DL := $05;
  169.     DH := Ord(LPTNo);
  170.   end;
  171.   MsDos(NovRegs);
  172. end;
  173.  
  174. function GetBannerUser : String;
  175. { returns the user name that is printed on the banner page }
  176.  
  177. var
  178.   Buf              : String;
  179.  
  180. begin
  181.   with NovRegs do begin
  182.     AX := $B808;
  183.     ES := Seg(Buf);
  184.     BX := Ofs(Buf);
  185.     MsDos(NovRegs)
  186.   end;
  187.   { process buf }
  188.   GetBannerUser := Buf;
  189. end;
  190.  
  191. end.
  192.