Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Emílio Gonçalves

Contar paginas impressas

Recommended Posts

Olá pessoal. Boa tarde! Estou fazendo um programa que gerencie o spoll de uma impressora. Este programa precisa me gerar um relatorio no final de cada dia dizendo: - Quantas paginas foi impressas no dia de hj. - Quais computadores que mandaram imprimir. Alguem pode me ajudar??? Desde já agradecido

Compartilhar este post


Link para o post
Compartilhar em outros sites

Pesquisei no site codecentral.borland.com e encontrei o seguinte:

 

Question: Is there any way to detect how many jobs are in the Windows printspooler at any given time?Answer: The Windows print spooler regularly broadcasts a system wideWM_SPOOLERSTATUS message each time a job is added or deleted from thespooler que. The following example demonstrates trapping for thismessage.Example:type  TForm1 = class(TForm)	Label1: TLabel;  private	{ Private declarations }	procedure WM_SpoolerStatus(var Msg : TWMSPOOLERSTATUS);	  message WM_SPOOLERSTATUS;  public	{ Public declarations }  end;var  Form1: TForm1;implementation{$R *.DFM}procedure TForm1.WM_SpoolerStatus(var Msg : TWMSPOOLERSTATUS);begin  Lable1.Caption := IntToStr(msg.JobsLeft) +					' Jobs currenly in spooler';  msg.Result := 0;end;
Dê uma olhada tb neste link

 

Outro exemplo interessante que encontrei no site www.tamaracka.com :

 

HiThere are of cource several ways, this is one of them!declare this in your mainform's private section  procedure WM_SpoolerStatus(var Msg : TWMSPOOLERSTATUS); messageWM_SPOOLERSTATUS;procedure TMainForm.WM_SPOOLERSTATUS(var Msg : TWMSPOOLERSTATUS);begin  msg.Result := 0;  JobsInQueueLbl.Caption := inttostr(msg.jobsleft) + ' on printer'; // ListJobsForprinter(PrinterName : String; var JobLV : TListView);end;depending of your needs you could use enumjobs to get even more informationabout jobsyou could make a Listview with a list for jobs for a specific printer likethis.remember to set viewstyle to vsreport and make some headers in the listview,or else it just will not work.procedure ListJobsForprinter(PrinterName : String; var JobLV : TListView);type  TJobInfo = array[0..0] of _JOB_INFO_2; // bruges til typecastingvar  p : pointer;  psize : dword;  ji2 : _JOB_INFO_2;  hGlobal : cardinal;  level: DWORD;  dwNeeded, dwReturned : DWORD;  bFlag : BOOLEAN;  i : dword;  ListItem : TListItem;  hPrinter : THandle;  pd : _PRINTER_DEFAULTS;  pPrinterName : Pchar;begin{$R-} // range checking udkoblet  try	p := nil;	level := 2;	bFlag := true;	JobLV.Items.Clear; // slet tidligere items fra liste	GetMem(pPrinterName,length(PrinterName)+1);	StrPCopy(pPrinterName,PrinterName);	// find printer handle og åben printer	zeromemory(@pd,sizeof(pd));	pd.DesiredAccess := PRINTER_ALL_ACCESS;	bFlag := OpenPrinter(pPrinterName, hPrinter, @pd);	if ((not bFlag) or (hPrinter = null)) then exit;	// først finder vi størrelsen på bufferen	dwneeded := 0;	dwreturned := 0;	bFlag := EnumJobs(hPrinter, 0, $FFFFFFFF, level, nil, 0, dwNeeded,dwReturned);	if (dwNeeded = 0) then exit; // dwneeded = 0 ~ måske ingen jobs fundet	getmem(p,dwneeded);	if (p = nil) then exit;	// her henter jeg så de ægte data	bFlag := EnumJobs(hPrinter, 0, $FFFFFFFF, level, p, dwNeeded, dwNeeded,dwReturned);	if (not bFlag) then exit;	// Loop igennem alle jobs og hent data.	with JobLV do	for i := 0 to dwReturned-1 do	begin	   Ji2 := TJobInfo(p^)[i];	   ListItem := Items.add;	   ListItem.Caption := inttostr(Ji2.JobID);	   ListItem.subitems.add(strpas(Ji2.pDocument));	   ListItem.subitems.add(strpas(Ji2.pUserName));	   if ji2.pStatus <> nil then ListItem.subitems.add(strpas(Ji2.pStatus))	   else	   case Ji2.Status of		  JOB_STATUS_PAUSED : ListItem.subitems.add(strpas('PAUSED'));		  JOB_STATUS_ERROR : ListItem.subitems.add(strpas('ERROR'));		  JOB_STATUS_DELETING : ListItem.subitems.add(strpas('DELETING'));		  JOB_STATUS_SPOOLING : ListItem.subitems.add(strpas('SPOOLING'));		  JOB_STATUS_PRINTING : ListItem.subitems.add(strpas('PRINTING'));		  JOB_STATUS_OFFLINE : ListItem.subitems.add(strpas('OFFLINE'));		  JOB_STATUS_PAPEROUT : ListItem.subitems.add(strpas('PAPEROUT'));		  JOB_STATUS_PRINTED : ListItem.subitems.add(strpas('PRINTED'));	   end;	end;  finally	if (p <> nil) then freemem(p,dwneeded);	if (pPrinterName <> nil) then freeMem(pPrinterName);	if (hPrinter <> null) then closeprinter(hPrinter);	if (not bFlag) then GetLastSystemError;	{$R+} // range checking indkoblet  end;end;Henrik

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.