PDA

Ver la Versión Completa : Como detecto cuando mandan imprimir desde Windows


SISCOYMAS
07-05-2007, 01:05:04
Hola !!!

:confused: Como puedo detectar cuando el usuario manda imprimir cualquier cosa en windows. ?

Gracias !!!


Saludos..
Alberto Fregoso
albertofregoso@gmail.com
alebeto19@hotmail.com

cHackAll
09-05-2007, 18:07:08
La siguiente propiedad es la que el Delphi nos da, SOLO funciona cuando TU aplicacion imprime algo mediante la unidad "Printers"

uses Printers;
begin
if Printer.Printing then ...
end.

Para saber si el S.O. está imprimiendo algo independientemente de tu aplicación pues te dejo el siguiente codigo:

uses WinSpool;

var Buffer: array [0..1024*1024-1] of Char;

function IsPrinting(lpPrinterName: PChar): LongBool;
var hPrinter, Count, Dummy: Cardinal; lpBuffer: PChar;
begin
Result := False;
if not OpenPrinter(lpPrinterName, hPrinter, nil) then Exit;
lpBuffer := @Buffer;
EnumJobs(hPrinter, 0, $FFFFFFFF, 1, lpBuffer, SizeOf(Buffer), Dummy, Count);
ClosePrinter(hPrinter);
while (Count <> 0) and not Result do
begin
Result := (PJobInfo1(lpBuffer).Status and JOB_STATUS_PRINTING) <> 0;
Inc(lpBuffer, SizeOf(TJobInfo1));
Dec(Count);
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if IsPrinting('Microsoft Office Document Image Writer') then
Caption := 'Imprimiendo...'
else
Caption := 'Impresora inactiva.';
end;

SISCOYMAS
10-05-2007, 08:21:04
Muchas Gracias por la ayuda !!!!
:D

!!!!!!!!
saludos..
Alberto Fregoso
albertofregoso@gmail.com