Página 2 de 2

Imprimir arquivo Texto em USB ou LPT

Enviado: 28 Ago 2014 19:00
por Itamar M. Lins Jr.
Ola!

Código: Selecionar todos


**********************************
Function Imprime(cArq,cPrint,cTit)
**********************************
*
*
Local oPrn, aPrn:=WIN_PRINTERLIST()
hb_default(@cPrint,win_PrinterGetDefault())
hb_default(@cTit,"PEDIDO")
If Empty(cArq)
   hwg_Msginfo('Informe algo p/ imprimir.')
   Return .F.
EndIf
If empty(aPrn)
   hwg_Msginfo('Não há impressoras instaladas')
   Return .F.
EndIf

If len(aPrn) = 1 //apenas uma impressora instalada.
   cPrint := iif(empty(cPrint),aPrn[1],cPrint)
EndIf

 nRet := Win_PrintFileRaw(cPrint,cArq,cTit)
 if nRet < 1
    cMsg := 'Erro Imprimindo: '
   SWITCH nRet
      CASE -1
         cMsg += "Parâmetro inválido passado" ; EXIT
      CASE -2
         cMsg += "WinAPI OpenPrinter() Falha na chamada"      ; EXIT
      CASE -3
         cMsg += "WinAPI StartDocPrinter() Falha na chamada"  ; EXIT
      CASE -4
         cMsg += "WinAPI StartPagePrinter() Falha na chamada" ; EXIT
      CASE -5
         cMsg += "WinAPI malloc() of memory failed"      ; EXIT
      CASE -6
         cMsg += "Arquivo " + cArq + " não Localizado"   ; EXIT
      //DEFAULT
      //   cMsg += cFile + " PRINTED OK!!!"
      END

     hwg_Msgstop(cMsg)
 EndIf

Return .T.
A lógica é mesma para a classe win_prn():New(cPrint) antiga win32prn() no xHB.

Saudações,
Itamar M. Lins Jr.

Imprimir arquivo Texto em USB ou LPT

Enviado: 29 Ago 2014 02:11
por Nascimento
Muito Obrigado amigo nesse FDS vou efetuar meus testes

Imprimir arquivo Texto em USB ou LPT

Enviado: 08 Set 2017 10:05
por paulovirt
O post é hiper-antigo, mas resolveu meu problema de hoje, 11 anos atrás.

Grato!