Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Impresión
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 27-10-2005
serhasae serhasae is offline
Miembro
 
Registrado: jun 2004
Ubicación: España
Posts: 117
Poder: 20
serhasae Va por buen camino
Estado de la impresora en windows xp

Hola he estado mirando los hilos que hablan sobre saber el estado de una impresora, antes de imprimir y con lo que hay en los foros no me aclaro, ya que todos especifican pero ninguno da un ejemplo concreto que funcione.

A ver todo el mundo apunta a GetPrinter, he estado mirando una estructura nueva que sale para Nt o Xp que es el que se llama en SetPrinter, ya que Getprinter no la tiene. Supongo que habria que usar GetPrinter, luego SetPrinter y una vez la tengas poder mirar el estado de la impresora con el registro siguiente, pero voy algo perdido, alguna sugerencia o codigo que funcione. Gracias. Saludos.


typedef struct _PRINTER_INFO_6 {

DWORD dwStatus;

} PRINTER_INFO_6;





Specifies the printer status. This member can be one of the following values:



Value Meaning

PRINTER_STATUS_BUSY The printer is busy.

PRINTER_STATUS_DOOR_OPEN The printer door is open.

PRINTER_STATUS_ERROR The printer is in an error state.

PRINTER_STATUS_INITIALIZING The printer is initializing.

PRINTER_STATUS_IO_ACTIVE The printer is in an active input/output state

PRINTER_STATUS_MANUAL_FEED The printer is in a manual feed state.

PRINTER_STATUS_NO_TONER The printer is out of toner.

PRINTER_STATUS_NOT_AVAILABLE The printer is not available for printing.

PRINTER_STATUS_OFFLINE The printer is offline.

PRINTER_STATUS_OUT_OF_MEMORY The printer has run out of memory.

PRINTER_STATUS_OUTPUT_BIN_FULL The printer's output bin is full.

PRINTER_STATUS_PAGE_PUNT The printer cannot print the current page.

PRINTER_STATUS_PAPER_JAM Paper is jammed in the printer

PRINTER_STATUS_PAPER_OUT The printer is out of paper.

PRINTER_STATUS_PAPER_PROBLEM The printer has a paper problem.

PRINTER_STATUS_PAUSED The printer is paused.

PRINTER_STATUS_PENDING_DELETION The printer is deleting a print job.

PRINTER_STATUS_PRINTING The printer is printing.

PRINTER_STATUS_PROCESSING The printer is processing a print job.

PRINTER_STATUS_TONER_LOW The printer is low on toner.

PRINTER_STATUS_UNAVAILABLE The printer is not available for printing.

PRINTER_STATUS_USER_INTERVENTION The user needs to do something to the printer.

PRINTER_STATUS_WAITING The printer is waiting.

PRINTER_STATUS_WARMING_UP The printer is warming up.

Responder Con Cita
  #2  
Antiguo 27-10-2005
Avatar de delphi.com.ar
delphi.com.ar delphi.com.ar is offline
Federico Firenze
 
Registrado: may 2003
Ubicación: Buenos Aires, Argentina *
Posts: 5.932
Poder: 27
delphi.com.ar Va por buen camino
Te traduje un código que utilizo en otro lenguaje, a ver si te sirve:
Código Delphi [-]
unit SpoolUtils;

interface

uses
  Windows;

function GetPrinterStatus(APrinterName: PChar): DWORD;

implementation

uses
  Printers, WinSpool, SysUtils;

function GetPrinterStatus(APrinterName: PChar): DWORD;
var
  HPrinter: THandle;
  BytesNeeded: Cardinal;
  PrinterDefaults: PRINTER_DEFAULTS;
  PI2: ^PRINTER_INFO_2;
begin
  with PrinterDefaults do
  begin
    DesiredAccess := PRINTER_ACCESS_USE;
    pDatatype := nil;
    pDevMode := nil;
  end;

  Win32Check(OpenPrinter(APrinterName, HPrinter, @PrinterDefaults));
  try
    if not GetPrinter(HPrinter, 2, nil, 0, @BytesNeeded) then
    begin
      GetMem(PI2, BytesNeeded);
      try
        if GetPrinter(HPrinter, 2, PI2, BytesNeeded, @BytesNeeded) then
          Result := PI2^.Status
        else
          Result := MaxWord;
      finally
        FreeMem(PI2);
      end;
    end
    else
      Result := MaxWord;
  finally
    ClosePrinter(HPrinter);
  end;
end;

end.
Saludos!
__________________
delphi.com.ar

Dedique el tiempo suficiente para formular su pregunta si pretende que alguien dedique su tiempo en contestarla.
Responder Con Cita
  #3  
Antiguo 27-10-2005
serhasae serhasae is offline
Miembro
 
Registrado: jun 2004
Ubicación: España
Posts: 117
Poder: 20
serhasae Va por buen camino
A ver explicame un par de cosas, tendre que pasarle el nombre de la impresora a la funcion y me devulve un numero que indica el estado?, o se puede indicar la impresora activa con alguna funcion. la he probado y siempre me devuelve 0. Donde miro los numeros a los que se refiere el estado. Gracias.
Responder Con Cita
  #4  
Antiguo 27-10-2005
Avatar de delphi.com.ar
delphi.com.ar delphi.com.ar is offline
Federico Firenze
 
Registrado: may 2003
Ubicación: Buenos Aires, Argentina *
Posts: 5.932
Poder: 27
delphi.com.ar Va por buen camino
Cita:
Empezado por serhasae
A ver explicame un par de cosas, tendre que pasarle el nombre de la impresora a la funcion y me devulve un numero que indica el estado?, o se puede indicar la impresora activa con alguna funcion. la he probado y siempre me devuelve 0.
No la puedo probar, yo utilizo un código similar en VB para saber si la impresora esta ocupada (aunque además averiguo si no hay trabajos en cola), y me ha funcionado sin problemas.

Cita:
Empezado por serhasae
Donde miro los numeros a los que se refiere el estado. Gracias.
Los resultados posibles son las constantes que pusiste en la pregunta. No te voy a poner una ayuda de lo que escribí, busca información sobre las apis que utilizo y trata de comprender el código. Lamento no poder ayudarte mas, espero que el código te sirva al menos para investigar!

Saludos!
__________________
delphi.com.ar

Dedique el tiempo suficiente para formular su pregunta si pretende que alguien dedique su tiempo en contestarla.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 18:49:55.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi