Lo suyo sería, según ayuda de xHarbour...
GETPRINTERS
Retrieve a list of available printers.
.. Syntax
GetPrinters() -->
.. Arguments
[<lPorts>] = .T. or .F. ( default .F. )
.. Returns
A List of available printers.
.. Description
This function retrieves a list of available printers.
.. Examples
CLS
?? 'Test program for WINDOWS printing'
? '---------------------------------'
? SET(_SET_DEVICE)
aPrinter:=GetPrinters()
IF EMPTY(aPrinter)
? '----- No Printers installed'
ELSE
set printer to (GetDefaultPrinter())
? SET(_SET_PRINTER)
? SET(_SET_PRINTFILE)
set console off
set printer on
? 'Default Printer'
?'----------------'
? GetDefaultPrinter()
?
? 'Printers Available'
?'-------------------'
FOR x:= 1 TO LEN(aPrinter)
? aPrinter[x]
NEXT x
aPrinter:= GetPrinters(.T.)
? 'Printers and Ports'
?'-------------------'
FOR x:= 1 TO LEN(aPrinter)
? aPrinter[x,1]+' on '+aPrinter[x,2]
NEXT x
EJECT
set printer off
set console on
set printer to
ENDIF
? SET(_SET_PRINTER)
? SET(_SET_DEVICE)
WAIT
return nil
.. Files
source is tprinter.c
Se puede utilizar como parámetro, .T. o .F. por si queremos saber la lista de puertos...
GetPrinters( .T. )
Eso debería devolver un Array con los puertos que tenemos en nuestro Windows...
Bien, pues por lo que veo... GetPrinters() devuelve un Array Vacio!!!
Por lo que respecta a IsPrinter()
ISPRINTER
Determine whether LPT1 is ready
.. Syntax
ISPRINTER() --> lReady
.. Arguments
None
.. Returns
ISPRINTER() returns true (.T.) if LPT1 is ready; otherwise, it returnsfalse (.F.).
.. Description
ISPRINTER() is a printer function that determines whether the parallelport (LPT1) is online and ready to print. ISPRINTER() ishardware-dependent and, therefore, only works on IBM BIOS compatiblesystems.
You can check ISPRINTER() to make sure the printer is ready before youbegin a print operation; however, if an error occurs during the printoperation, a runtime error is generated.
.. Examples
This example tests the parallel port for readiness with up to
25 retries. If the parallel port is ready, the printer operation
begins:
lReady := ISPRINTER()
//
IF lReady
REPORT FORM Sales TO PRINTER
ELSE
? "Printer not ready..."
BREAK
ENDIF
.. Files
Library is rtl.lib, source is isprint.c
Pues desde Xailer... IsPrinter() lanza un GPF
Para que no lanze el GPF, debemos enviar algún parámetro a la Función...
IsPrinter("loquesea")
Pero SIEMPRE devuelve .F.
Si he entendido bien lo que he leído,...
Creo que hay problemas con los puertos LPTs y Xailer
Gracias.
Un Saludo,
Xevi.
"José Luis Capel" <
joseluis@iaicom.com> escribió en el mensaje news:[email=
43873dbe@ozsrvnegro.ozlan.local...]
43873dbe@ozsrvnegro.ozlan.local...[/email]
> Xevi,
>
> Pues me quedo pillado...
>
> He revisado el fuente de xIsprinter y veo que utiliza una función del
> Api de Windows ( OpenPrinter ) que abre un 'handle' a la impresora. Lo
> que no se, mirando el MSDN, es si el nombre de la impresora corresponde
> a "LPTx" o no. A ver si algún experto en la materia puede aclararnos
> algo más esto.
>
> Saludos,
> José Luis Capel
>
>
> Xevi escribió:
>>
>> MsgInfo( xIsPrinter("LPT1") )
>> MsgInfo( xIsPrinter("LPT2") )
>> MsgInfo( xIsPrinter("LPT3") )
>> MsgInfo( xIsPrinter("LPT4") )
>> MsgInfo( xIsPrinter("LPT5") )
>>
>> SIEMPRE devuelve -1, exista o no el puerto, o esté o no esté lista la
>> impresora conectada en LPT1
>>
>> Gracias.
>>
>> Un Saludo,
>> Xevi.
>>
>>
>> "José Luis Capel" <
joseluis@iaicom.com> escribió en el mensaje
>> news:[email=
438734b0@ozsrvnegro.ozlan.local...]
438734b0@ozsrvnegro.ozlan.local...[/email]
>>
>>>Xevi,
>>>
>>>IsPrinter solo funciona con LPT1 y no acepta parámetros.
>>>
>>>Prueba con xIsPrinter("LPTn") y dime se eso te soluciona el problema.
>>>
>>>Saludos,
>>>José Luis Capel
>>>
>>>Xevi escribió:
>>>
>>>>Jose,
>>>> IsPrinter() no me funciona... o no se hacerlo funcionar !!!
>>>> En un ordenador con puerto LPT1, y una impresora conectada y
>>>>encendida...
>>>>MsgInfo( IsPrinter( "LPT1" ) )
>>>>MsgInfo( IsPrinter( "LPT2" ) )
>>>>MsgInfo( IsPrinter( "LPT3" ) )
>>>>MsgInfo( IsPrinter( "LPT1:" ) )
>>>>MsgInfo( IsPrinter( "LPT2:" ) )
>>>>MsgInfo( IsPrinter( "LPT3:" ) )
>>>>La respuesta es SIEMPRE la misma F.
>>>>¿Hago algo mal???
>>>> y otra consulta sobre imprimir e interceptar el error...
>>>> En Clipper existía el objeto oError, que podíamos "interceptar" e
>>>>incluso "modificar" en el prg... ErrorSys.prg.
>>>>¿Cómo podemos interceptar los errores en Xailer/xHarbour???
>>>>Ya que si mando a imprimir
>>>>SET DEVICE TO PRINTER
>>>>SET PRINTER TO LPT5
>>>>y el puerto no existe
>>>>me lanza un error Xailer/xHarbour... y me "saca" de la aplicación
>>>>Subsistema: TERM
>>>> Código de error: 2014
>>>> Estado: .T.
>>>> Descripción: Create error
>>>> Operación: LPT5.prn
>>>> Argumentos:
>>>> Fichero:
>>>> Código error SO: 2
>>>> Pila de llamadas:
>>>> SET (0)
>>>> MAIN (17)
>>>> Gracias.
>>>> Un Saludo,
>>>>Xevi.
>>>> "Jose F. Gimenez" <
jfgimenez@wanadoo.es> escribió en el
>>>>mensaje news:[email=
4385fe07@ozsrvnegro.ozlan.local...]
4385fe07@ozsrvnegro.ozlan.local...[/email]
>>>> >
>>>> > Xevi,
>>>> >
>>>> >> ¿Como compruebo si el puerto LPT1 local está disponible???
>>>> >>
>>>> >> Habría algun Wrapper para puertos LOCALES
>>>> >>
>>>> >> Algo como... WLocalGetConnection
>>>> >>
>>>> >> Se trataría primero de intentar localizar el puerto localmente y si
>>>>no
>>>> >> está disponible intentar localizarlo en la Red.
>>>> >
>>>> > ¿Has probado IsPrinter() en el puerto local? Podrías usar
>>>> > WNetGetConnection() para comprobar si es un puerto de red, y si no lo
>>>>es,
>>>> > comprobarlo con IsPrinter(). Yo creo que así sí debería funcionar
>>>>bien.
>>>> >
>>>> >
>>>> > --
>>>> > Un saludo,
>>>> >
>>>> > José F. Giménez
>>>> >
>>>> >
>>>> >
>>>
>>
>>
>>
>
--