[Lazarus-es] impresion en red

Maxi maximiliano.duarte en gmail.com
Jue Ago 29 16:20:43 CEST 2013


He estado haciendo un par de pruebas, en delphi y en lazarus. Y
encontré un par de cosas, primero que en Laz es muy diferente a la
implementacion hecha en Delphi, está mas simple en Lazarus.

Con este codigo hice algunas pruebas y debug
var
   s:string;
   f:integer;

begin
    For f:=0 to Printer.Printers.Count -1 do
    Begin
         Printer.PrinterIndex:=f;
         Printer.SetPrinter(Printer.PrinterName);
         case Printer.PrinterType of
              ptLocal   : s:= 'LOCAL'+ char(9);
              ptNetWork : s:= 'REMOTO'+ char(9);
         end;
         Memo1.Lines.Add(s+ Printer.PrinterName);
    end;

En Laz hay una propiedad Printer.PrinterType que deberia devolver si
es remota o local, pero siempre devuelve local.
En degug encuentro que en el codigo debuelve distintos valores para
local y remoto pero las constantes comparadas tienen otro valor.

unit winprinters.inc
function TWinPrinter.GetPrinterType: TPrinterType;
var
  Size: Dword;
  InfoPrt: Pointer;
begin
  Result := ptLocal;
  //On Win9X all printers are local
  if Win32Platform <> VER_PLATFORM_WIN32_NT then Exit;

  GetPrinter(fPrinterHandle, 4, nil, 0, @Size);
  GetMem(InfoPrt, Size);
  try
  if not GetPrinter(fPRinterHandle, 4, InfoPrt, Size, @Size)
  then
    raise EPrinter.CreateFmt('GetPrinterType failed : %s',
        [SysErrorMessage(GetLastError)]);
  if PPRINTER_INFO_4(InfoPrt)^.Attributes = PRINTER_ATTRIBUTE_NETWORK then
     Result := ptNetwork;
  finally
    FreeMem(InfoPrt);
  end;
end;

Unit winutilprnconst.inc
PRINTER_ATTRIBUTE_NETWORK           = $00000010; //Printer is a
network printer connection
PRINTER_ATTRIBUTE_LOCAL             = $00000040; //Printer is a local printer


cuando la impresora es remota retorna 3608, cuando es local 2112

Otra cosa rara es que el debug entra a otra unidad y no a la printers.
que este es el codigo Alguien me explique porfavor

//Return the type of selected printer
function TPrinter.GetPrinterType: TPrinterType;
begin
  Result:=ptLocal;
end;

-- 
El que pregunta aprende, y el que contesta aprende a responder.

No a la obsolecencia programada:
http://www.rtve.es/noticias/20110104/productos-consumo-duran-cada-vez-menos/392498.shtml

Linux User #495070
http://domonetic.com/blog




More information about the Lazarus-es mailing list