procedure TForm1.Button6Click(Sender: TObject);
var id:string;
jobid:Cardinal;
ListItem: TListItem;
begin
if lv.Selected=nil then
Exit;
id:=lv.Selected.Caption;
if id='' then
Exit;
if MessageDlg('Are you sure you want to delete this Print job?',
mtConfirmation, [mbYes, mbNo], 0) = mrNo then
exit;
jobid:=StrToInt(id);
setJob(DevM,Jobid,0,@Jobs,JOB_CONTROL_CANCEL);
//ListItem:=lvt.Items.Add;
//listItem.Caption:=id;
//listItem.SubItems:=lv.Selected.SubItems;
ListViewDeleteRow(id,lv);
end;
procedure TForm1.Button7Click(Sender: TObject);
var
Dev, Drv, Prt: Array[0..255] of Char;
DM1: PDeviceMode;
DM2: PDeviceMode;
Sz: Integer;
begin
Printer.PrinterIndex := -1;
{ 1 Default }
Printer.GetPrinter(Dev, Drv, Prt, DevM);
If OpenPrinter(Dev,DevM,nil) then
begin
//If EnumJobs(DevM,0,10,1,@JI,SizeOf(TJOBINFO1)+128,Need,Return) then
begin
If EnumJobs(DevM,0,20,1,@JI,SizeOf(JI),Need,Return) then
begin
if Return<0 then
exit;
//if EnumJobs(DevM,FirstJob,LastJob+1,InfoLevel,@Jobs,SizeOf(Jobs),BytesNeeded,NumJobs) then
begin
showmessage(inttostr(ji[0].JobId));
showmessage(StrPas(Ji[0].pStatus));
If JI[0].JobId>0 then
begin
showMessage(Format('正在打印: %s / %d',[StrPas(JI[0].pStatus),JI[0].TotalPages]));
end;
end else
showmessage('bad');
end;
end;
end.