给段代码,一般情况下,你所需要的功能需要用到API来实现。
procedureTForm1.Button1Click(Sender:TObject);
var
LPHandle:THandle;//打印机句柄
LPStrBuf:Array[0..256]ofChar;//打印机名称
NoJobs:Word;//希望获取的作业数
s:LongWord;//Job_Info的字节数
Job_Info:array[0..10]ofJOB_INFO_1;//打印队列信息
cbNeeded:Cardinal;
cReturned:Cardinal;//返回的作业数
ret:LongBool;
I:Integer;
begin
LPStrBuf:='HPLaserJetIII';//指定打印机名称
//打开打印机
if(OpenPrinter(LPStrBuf,LPHandle,nil)=False)then
begin
MessageBox(Form1.Handle,'打开打印机失败。','信息',MB_OK);
Exit;//退出
end;
s:=Sizeof(Job_Info);
cbNeeded:=0;
cReturned:=0;
NoJobs:=10;
ret:=EnumJobs(LPHandle,
0,
NoJobs,
1,
@Job_Info,
s,
cbNeeded,
cReturned);
//显示打印队列信息
Memo1.Lines.Add('共有打印任务:'+IntToStr(cReturned)+'个。');
forI:=0tocReturned-1do
Memo1.Lines.Add('第'+IntToStr(I+1)+'个打印任务有'
+IntToStr(Job_Info.TotalPages)+'页。');
end;