怎样能知道打印任务已经完成?300分(100分)

  • 主题发起人 主题发起人 cypl
  • 开始时间 开始时间
C

cypl

Unregistered / Unconfirmed
GUEST, unregistred user!
我想实现连续打印,比如100条记录打印在专门印制的100张连续的卡片上,一条记录打印在<br>一张卡片上,循环打印完,但中间想能控制,否则就一次发了100条打印信息,无法控制,我<br>就想当获取一条记录打印完成后的信息,然后在发第二条记录,这样好控制,但不知道如何<br>获取打印完成的信息,搜索了一下以前的帖子,找到了一段代码,但无法编译,帮忙看看!<br>我还没搞懂API函数的用法,请各位帮忙指点一二,最好能详细讲讲,谢谢!<br><br>procedure Tform1.GetJobs(PrinterName: String);<br>const<br>&nbsp; InfoLevel = 1;<br>&nbsp; FirstJob = 0;<br>&nbsp; LastJob = 19;<br>var<br>&nbsp; Jobs: array [FirstJob..LastJob] of TJobInfo1;<br>&nbsp; PrinterHandle:Cardinal;<br>&nbsp; BytesNeeded, NumJobs: Cardinal;<br>&nbsp; I:integer;<br>&nbsp; jobid:Cardinal;<br>&nbsp; cur_row:integer;<br>&nbsp; rows:olevariant;<br>begin<br>&nbsp; if OpenPrinter(PChar(PrinterName),Printerhandle,nil) then begin<br>&nbsp; &nbsp; if EnumJobs(PrinterHandle,FirstJob,LastJob,1,InfoLevel,Jobs,SizeOf(Jobs),BytesNeeded,NumJobs) then begin<br>&nbsp; &nbsp; &nbsp; if NumJobs&gt;0 then &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rows:=VarArrayCreate([0,10, 0, 0], varVariant);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for I := 0 to NumJobs-1 do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; with Jobs do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cur_row:=VarArrayHighBound(rows, 2);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rows[0, cur_row]:=JobId;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rows[1, cur_row]:=StrPas(pPrinterName);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rows[2, cur_row]:=StrPas(pMachineName);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rows[3, cur_row]:=StrPas(pUserName);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rows[4, cur_row]:=StrPas(pDatatype);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rows[5, cur_row]:=StrPas(pDocument);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rows[6, cur_row]:=StrPas(pStatus);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rows[7, cur_row]:=Priority;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rows[8, cur_row]:=Position;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rows[9, cur_row]:=TotalPages;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rows[10, cur_row]:=PagesPrinted;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; VarArrayRedim(rows, cur_row + 1);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setJob(DevM,Jobid,0,@Jobs,JOB_CONTROL_PAUSE);<br><br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp;lv.Items.Clear;<br>&nbsp; &nbsp; &nbsp; &nbsp;ListViewAddRows(rows,lv);<br>&nbsp; &nbsp; &nbsp; &nbsp;//ClosePrinter(PrinterHandle);<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br><br>end;<br>
 
我输的300分,怎么变成100分了?反正我给300分!
 
EnumJobs <br><br>VB声明 <br>Declare Function EnumJobs Lib "winspool.drv" Alias "EnumJobsA" (ByVal hPrinter As Long, ByVal FirstJob As Long, ByVal NoJobs As Long, ByVal Level As Long, pJob As Byte, ByVal cdBuf As Long, pcbNeeded As Long, pcReturned As Long) As Long <br>说明 <br>枚举打印队列中的作业 <br>返回值 <br>Long,非零表示成功,零表示失败。会设置GetLastError <br>参数表 <br>参数 类型及说明 <br>hPrinter Long,一个已打开的打印机对象的句柄(用OpenPrinter获得) <br>FirstJob Long,作业列表中要枚举的第一个作业的索引(注意编号从0开始) <br>NoJobs Long,要枚举的作业数量 <br>Level Long,1或2 <br>pJob Byte,包含 JOB_INFO_1 或 JOB_INFO_2 结构的缓冲区 <br>cbBuf Long,pJob缓冲区中的字符数量 <br>pcbNeeded Long,指向一个Long型变量的指针,该变量用于保存请求的缓冲区长度,或者实际读入的字节数量 <br>pcReturned Long,载入缓冲区的结构数量(用于那些能返回多个结构的函数) <br><br><br><br>SetJob <br><br>VB声明 <br>Declare Function SetJob Lib "winspool.drv" Alias "SetJobA" (ByVal hPrinter As Long, ByVal JobId As Long, ByVal Level As Long, pJob As Byte, ByVal Command As Long) As Long<br>&nbsp;<br>说明 <br>&nbsp; 对一个打印作业的状态进行控制。 <br>返回值 <br>Long,非零表示成功,零表示失败。会设置GetLastError <br>参数表 <br>参数 类型及说明 <br>hPrint Long,指定一个打开打印机的句柄(用openprinter取得) <br>JobId Long,要修改的作业的编号 <br>Level Long,0,1或2 <br>pJob Byte,指定一个缓冲区。如级别(Level)设为1或2,那该缓冲区就包含了一个JOB_INFO_1或JOB_INFO_2结构。如级别为0,缓冲区为NULL(变成ByVal As Long,以便传递零值)。如指定了一个结构,则来自那个结构的信息会用于改变打印作业的设置(除JobId,pPrinterName,pMachineName,pDriverName,Size,Submitte以及Time字段外) <br>Command Long,下述常数之一: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>JOB_CONTROL_CANCEL:取消作业 <br>JOB_CONTROL_PAUSE :暂停作业 <br>JOB_CONTROL_RESTART:重新启动一个已开始打印的作业 <br>JOB_CONTROL_RESUME:恢复一个暂停的作业 <br><br>
 
接受答案了.
 
后退
顶部