Spool - Informações de impressão!!!
Alguem conhece uma maneira ou componente que retorne informações de um documento que está sendo impresso?
Eu preciso verificar quem está utilizando uma impressora em rede e quanto de páginas estão sendo impressas.
Obrigado
Eu preciso verificar quem está utilizando uma impressora em rede e quanto de páginas estão sendo impressas.
Obrigado
Glauberms
Curtidas 0
Respostas
Aroldo Zanela
26/07/2003
Colega,
Dá uma olhada neste material: http://216.101.185.148/scripts/isapi.dll/article?id=386567A5&article=4506810
Dá uma olhada neste material: http://216.101.185.148/scripts/isapi.dll/article?id=386567A5&article=4506810
GOSTEI 0
Glauberms
26/07/2003
Obrigado mas eu acho que a página espirou. Não consigo ver o material. :(
Se não for pedir muito, poderia verificar pra mim?
Obrigado outra vez...
Se não for pedir muito, poderia verificar pra mim?
Obrigado outra vez...
GOSTEI 0
Aroldo Zanela
26/07/2003
Colega,
Procure em www.tamaracka.com
entre com uma pesquisa da seguinte forma (sugestão):
print and monitoring and ^delphi
Você encontrará um bocado de informação (e lixo) que poderá lhe ajudar na pesquisa e conclusão do seu problema:
Procure em www.tamaracka.com
entre com uma pesquisa da seguinte forma (sugestão):
print and monitoring and ^delphi
Você encontrará um bocado de informação (e lixo) que poderá lhe ajudar na pesquisa e conclusão do seu problema:
Hi
There are of cource several ways, this is one of them!
declare this in your mainform´s private section
procedure WM_SpoolerStatus(var Msg : TWMSPOOLERSTATUS); message
WM_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 information
about jobs
you could make a Listview with a list for jobs for a specific printer like
this.
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 typecasting
var
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
GOSTEI 0