IsPrinter()

IsPrinter()

Postby cmsoft » Wed Jun 18, 2014 11:58 am

Estimados:
Quiero controlar, antes de mandar a imprimir con TDosPrn a una tiqueadora Epson TM-U220 conectada al puerto LPT1, si la misma se encuentra ONLINE.
Uso la función IsPrinter("LPT1") y la misma siempre me devuelve .f.
Si utilizo la función IsPrinter(1), siempre me devuelve .t. aunque no esté ONLINE la impresora, y el programa se queda esperando indefinidamente.
Alguien lo hace de alguna otra forma, o ha tenido el mismo inconveniente?
Para destacar, el puerto donde tengo conectada la impresora es un puerto PCI (En el administrador de dispositivos de Windows figura como "PCI_LPT (LPT1) ")
Gracias de antemano.
User avatar
cmsoft
 
Posts: 1204
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: IsPrinter()

Postby karinha » Wed Jun 18, 2014 12:35 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7350
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: IsPrinter()

Postby cmsoft » Wed Jun 18, 2014 1:11 pm

Gracias por responder Karinha, pero no me funciona!
La impresora está lista en el puerto LPT1 pero la función que me pasaste siempre me devuelve el Status 4096.
La impresora no está instalada (de hecho no es necesario instalarla, porque imprime directo en LPT1)
Gracias igual
User avatar
cmsoft
 
Posts: 1204
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: IsPrinter()

Postby karinha » Wed Jun 18, 2014 4:08 pm

Porfa, muestra un ejemplo sencillo de como estás haciendo.

Gracias, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7350
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: IsPrinter()

Postby Hector Pedro Lerda » Wed Jun 18, 2014 4:48 pm

Buen dia,

Estas impresoras las debes de instalar como

Fabricante : Generic
Impresoras: Generic / Text Only

Prueba de este modo.

Saludos Pedro Lerda
User avatar
Hector Pedro Lerda
 
Posts: 46
Joined: Tue May 07, 2013 7:27 pm
Location: Buenos Aires - Argentina

Re: IsPrinter()

Postby cmsoft » Thu Jun 19, 2014 11:32 am

Porfa, muestra un ejemplo sencillo de como estás haciendo.

Code: Select all  Expand view
 
STATIC FUNCTION Impresion( oQry )
LOCAL oPrn
IF !IsPrint("LPT1:")
   RETURN nil
ENDIF
oPrn := TDosPrn():New("LPT1")
...

La funcion IsPrint es la que me pasaste vos Karinha. Tambien use la funcion IsPrinter() y esta siempre me devolvia .t., estuviera o no prendida la impresora. La función tuya siempre me devuelve Status 4096
Estas impresoras las debes de instalar como

Fabricante : Generic
Impresoras: Generic / Text Only

La instalé asi, generira, y sigue dando el mismo error.
Gracias a los 2 por responder
User avatar
cmsoft
 
Posts: 1204
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: IsPrinter()

Postby karinha » Fri Jun 20, 2014 3:06 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7350
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: IsPrinter()

Postby cmsoft » Mon Jun 23, 2014 11:48 am

Hola Karhina!
Segui el link que me enviaste, pero no tiene la referencia a las solución que busco, que basicamente es tener una función que valide que el puerto LPT1 tenga una impresora ONLINE, mas allá de que la misma esté instalada o no.
Gracias por tu tiempo.
User avatar
cmsoft
 
Posts: 1204
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: IsPrinter()

Postby karinha » Mon Jun 23, 2014 12:02 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7350
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: IsPrinter()

Postby cmsoft » Wed Jun 25, 2014 11:26 pm

Gracias João, pero sigue sin ser la solución.
Necesitaria la vieja funcion ISPRINTER() de clipper, que detectaba si la impresora estaba en linea en el puerto LPT1. Este o no instalada en Windows
User avatar
cmsoft
 
Posts: 1204
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: IsPrinter()

Postby Antonio Linares » Thu Jun 26, 2014 1:27 pm

Cmsoft,

En Windows no puedes realizar esa comprobación si la impresora no está instalada en Windows, puesto que Windows controla todos sus dispositivos (no hay forma de "saltárselo"). Es muy diferente a MsDos.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41406
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: IsPrinter()

Postby karinha » Thu Jun 26, 2014 2:04 pm

Maestro Antonio, no es posible hacer algo asi, usando PRINTUI.DLL ?

Code: Select all  Expand view

RUNDLL32 PRINTUI.DLL,PrintUIEntry /?

Notes:  (1) I certainly did not test each of these switches myself!
To be honest, I usually prefer to use the (VBScript) printer management scripts that come with Windows 2000 and later (%windir%\System32\*prn*.vbs).
(2) In Windows 7, PRINTUI.EXE can be used as shorthand for RUNDLL32 PRINTUI.DLL,PrintUIEntry
More information is available at Microsoft's TechNet under Q189105.

Download Microsoft'
s PrintUI.DLL User's Guide and Reference for more detailed, task oriented explanations of command line options.

Usage:

RUNDLL32 PRINTUI.DLL,PrintUIEntry [ options ] [ @commandfile ]

/a[file]    binary file name
/b[name]    base printer name
/c[name]    unc machine name if the action is on a remote machine
/dl delete local printer
/dn delete network printer connection
/dd delete printer driver
/e  display printing preferences
/f[file]    either inf file or output file
/ga add per machine printer connections
/ge enum per machine printer connections
/gd delete per machine printer connections
/h[arch]    driver architecture, one of the following:
Alpha | Intel | Mips | PowerPC
/ia install printer driver using inf file
/id install printer driver using add printer driver wizard
/if install printer using inf file
/ii install printer using add printer wizard with an inf file
/il install printer using add printer wizard
/in add network printer connection
/j[provider]    print provider name
/k  print test page to specified printer, cannot be combined with command when installing a printer
/l[path]    printer driver source path
/m[model]   printer driver model name
/n[name]    printer name
/o  display printer queue view
/p  display printer properties
/q  quiet mode, do not display error messages
/r[port]    port name
/s  display server properties
/Ss Store printer settings into a file
/Sr 
Restore printer settings from a file
Store or restore printer settings option flags that must be placed at the end of command:
2   PRINTER_INFO_2
7   PRINTER_INFO_7
c   Color Profile
d   PrinterData
s   Security descriptor
g   Global DevMode
m   Minimal settings
u   User DevMode
r   Resolve name conflicts
f   Force name
p   Resolve port
/u  use the existing printer driver if it'
s already installed
/t[#]   zero based index page to start on
/v[version] driver version, one of the following:
Windows 95 or 98 | Windows NT 3.1 | Windows NT 3.5 or 3.51 | Windows NT 3.51 | Windows NT 4.0 | Windows NT 4.0 or 2000 | Windows 2000
/w  prompt the user for a driver if specified driver is not found in the inf
/y  set printer as the default
/Xg get printer settings
/Xs set printer settings
/z  do not auto share this printer
/Z  share this printer, can only be used with the /if option
/?  help this message
@[file] command line argument file

Examples:

Run server properties:
RUNDLL32 PRINTUI.DLL,PrintUIEntry /s /t1 /n\\machine

Run printer properties
RUNDLL32 PRINTUI.DLL,PrintUIEntry /p /n\\machine\printer

Run add printer wizard localy
RUNDLL32 PRINTUI.DLL,PrintUIEntry /il

Run add printer wizard on \\machine
RUNDLL32 PRINTUI.DLL,PrintUIEntry /il /c\\machine

Run queue view
RUNDLL32 PRINTUI.DLL,PrintUIEntry /o /n\\machine\printer

Run inf install
RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b "Test Printer" /f %windir%\inf\ntprint.inf /r "lpt1:" /m "AGFA-AccuSet v52.3"

Run add printer wizard using inf
RUNDLL32 PRINTUI.DLL,PrintUIEntry /ii /f %windir%\inf\ntprint.inf

Add per machine printer connection
RUNDLL32 PRINTUI.DLL,PrintUIEntry /ga /c\\machine /n\\machine\printer /j"LanMan Print Services"

Delete per machine printer connection
RUNDLL32 PRINTUI.DLL,PrintUIEntry /gd /c\\machine /n\\machine\printer

Enumerate per machine printer connections
RUNDLL32 PRINTUI.DLL,PrintUIEntry /ge /c\\machine

Add printer driver using inf
RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /c\\machine /m "AGFA-AccuSet v52.3" /h "Intel" /v "Windows 2000" /f %windir%\inf\ntprint.inf

Remove printer driver
RUNDLL32 PRINTUI.DLL,PrintUIEntry /dd /c\\machine /m "AGFA-AccuSet v52.3" /h "Intel" /v "Windows 2000"

Set printer as default
RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "printer"

Set printer comment
RUNDLL32 PRINTUI.DLL,PrintUIEntry /Xs /n "printer" comment "My Cool Printer"

Set printer port
RUNDLL32 PRINTUI.DLL,PrintUIEntry /Xs /n "printer" PortName "port:"

Get printer settings
RUNDLL32 PRINTUI.DLL,PrintUIEntry /Xg /n "printer"

Get printer settings saving results in a file
RUNDLL32 PRINTUI.DLL,PrintUIEntry /f "results.txt" /Xg /n "printer"

Set printer settings command usage
RUNDLL32 PRINTUI.DLL,PrintUIEntry /Xs /n "printer" ?

Store all printer settings into a file
RUNDLL32 PRINTUI.DLL,PrintUIEntry /Ss /n "printer" /a "file.dat"

Restore all printer settings from a file
RUNDLL32 PRINTUI.DLL,PrintUI /Sr /n "printer" /a "file.dat"

Store printer information on level 2 into a file
RUNDLL32 PRINTUI.DLL,PrintUIEntry /Ss /n "printer" /a "file.dat" 2

Restore from a file printer security descriptor
RUNDLL32 PRINTUI.DLL,PrintUIEntry /Sr /n "printer" /a "file.dat" s

Restore from a file printer global devmode and printer data
RUNDLL32 PRINTUI.DLL,PrintUIEntry /Sr /n "printer" /a "file.dat" g d

Restore from a file minimum settings and resolve port name
RUNDLL32 PRINTUI.DLL,PrintUIEntry /Sr /n "printer" /a "file.dat" m p

/*
C:\Windows\System32

20/11/2010  09:20           932.352 printui.dll
*/

 


Saludos
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7350
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: IsPrinter()

Postby Antonio Linares » Thu Jun 26, 2014 2:10 pm

João,

En todo caso se podría detectar si una impresora está instalada en otro ordenador con Windows, pero para comprobar si la impresora está instalada en Windows, tiene que estar instalada previamente ó Windows no la reconocerá.

En MsDos era diferente porque podíamos "hablar" directamente con el puerto, pero en Windows eso no está permitido salvo que sea el código de un driver, que son los únicos que pueden acceder a ese nivel de hardware.

De todas formas esto lo analizo aplicando la lógica, desconozco si existe alguna forma que permita saltarse esta lógica.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41406
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 34 guests