Saber si hay impresora conectada(SOLUCIONADO)

Saber si hay impresora conectada(SOLUCIONADO)

Postby Armando » Thu Dec 09, 2021 8:09 pm

Saludos amigos del foro:

Necesito saber si en un PC tiene o no impresora conectada, alguien
que tenga algo de código?

Saludos
Last edited by Armando on Fri Dec 10, 2021 1:36 am, edited 1 time in total.
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3184
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Saber si hay impresora conectada

Postby karinha » Thu Dec 09, 2021 8:31 pm

Estimado, intenta asi:

Code: Select all  Expand view

// Printing a whole window sample
// You may use also :hardCopy() method without creating a PRINT object

#include "FiveWin.ch"

#define PAD_LEFT            0
#define PAD_RIGHT           1
#define PAD_CENTER          2

static oWnd

MEMVAR nCopias

FUNCTION Main()

   nCopias := 2  // ponga en el dialogo Number of copies.

   DEFINE WINDOW oWnd FROM 1, 1 TO 20, 60 TITLE "Printing a Window"

   @ 3, 3 BUTTON "&Print me" OF oWnd SIZE 80, 20 ;
      ACTION PrintMe_Copias()  // try also with oWnd:HardCopy()

   ACTIVATE WINDOW oWnd

RETURN NIL

FUNCTION PrintMe_Copias()

   LOCAL nI

   FOR nI := 1 TO nCopias

      SYSREFRESH()

      PrintMe()

   NEXT

RETURN NIL

FUNCTION PrintMe()

   LOCAL oPrn, oFont, oPen, aPrn
   LOCAL nLinI, nColI, nLinF, nColF

   aPrn := GetPrinters()

   IF Empty( aPrn ) // Empty( oPrn:hDC )

      MsgStop ("No se encontró impresora", "No se encontró impresora")

      RETURN NIL

   ENDIF

   PRINTER oPrn PREVIEW MODAL // PARA TESTAR A IMPRESSORA ANTES DE IMPRIMIR

   IF EMPTY( oPrn:hDC )

       MsgInfo ("HABÍA ALGO MAL CON LA IMPRESORA", "ENCIENDA LA IMPRESORA")

      oPrn:End()

      RETURN( .F. )

   ENDIF

   oPrn:End()

   PRINT oPrn NAME "Impresión en Vertical.." PREVIEW

      DEFINE FONT oFont NAME "Arial" SIZE 0, -10 BOLD OF oPrn
      DEFINE PEN oPen WIDTH  2                        OF oPrn
 
      oPrn:SetPage(9)    // A4
      oPrn:SetPortrait() // Vertical

      PAGE

         nLinI :=  0.90
         nColI :=  0.90
         nLinF := 28.6
         nColF := 20.0

         oPrn:Cmtr2Pix(@nLinI, @nColI)
         oPrn:cmtr2Pix(@nLinF, @nColF)
         oPrn:Box(nLinI, nColI, nLinF, nColF, oPen  )
         oPrn:cmSay( 1.0,  1.0, "Superior Izquierda", oFont,,CLR_BLACK,,PAD_LEFT  )
         oPrn:cmSay( 1.0, 10.5, "Superior Centro",    oFont,,CLR_BLACK,,PAD_CENTER )
         oPrn:cmSay( 1.0, 20.0, "Superior Derecha",   oFont,,CLR_BLACK,,PAD_RIGHT )
         oPrn:cmSay(28.0,  1.0, "Inferior Izquierda", oFont,,CLR_BLACK,,PAD_LEFT  )
         oPrn:cmSay(28.0, 10.5, "Inferior Centro",    oFont,,CLR_BLACK,,PAD_CENTER )
         oPrn:cmSay(28.0, 20.0, "Inferior Derecha",   oFont,,CLR_BLACK,,PAD_RIGHT )

      ENDPAGE

   ENDPRINT


   /*
   PRINT oPrn NAME "Test"

      PAGE

        // oWnd:Print( oPrn, 1, 1, 2 )        // Scale factor 2


      ENDPAGE

   ENDPRINT
   */


RETURN NIL

//----------------------------------------------------------------------------//
 


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

Re: Saber si hay impresora conectada

Postby Armando » Fri Dec 10, 2021 1:35 am

Karinha

Muchas gracias, solucionado.

Saludos
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3184
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Cgallegoa and 73 guests

cron