Pessoal,
Espero que todos estejam bem.
Estou migrando do ACBrMonitor para o ACBrLib e estou com um sério problema.
Não consigo imprimir NFe e SAT sem antes sair da aplicação.
Por favor, deem uma olhada onde estou errando.
#include 'FIVEWIN.CH'
#define DLL_CDECL 0x08
#define DLL_STDCALL 0x20
#define DLL_SYSTEM 0x04
#define STR_LEN 256
function Main()
local oWnd
define window oWnd from 5,5 to 30,85 title "ACBrLib Teste"
@ 3,10 BUTTON "Imprime NF-e" size 100,50 OF oWnd ACTION ImprimirNFE()
@ 3,40 BUTTON "Imprime SAT" size 100,50 OF oWnd ACTION ImprimirSAT()
set message of oWnd to "Teste ACBrLib" date time noinset
activate window oWnd centered
return nil
static function ImprimirNFE(eArquivoOuXml, cImpressora, nNumCopias, cProtocolo, bMostrarPreview, cMarcaDagua, bViaConsumidor, bSimplificado)
local hResult, bufferLen, buffer, oErr
local oDll := DllLoad( 'ACBrNFe32.dll' )
eArquivoOuXml := if(eArquivoOuXml=nil, "acbrnfe.xml", eArquivoOuXml)
cImpressora := if(cImpressora=nil, "", cImpressora)
nNumCopias := if(nNumCopias=nil, 1, nNumCopias)
cProtocolo := if(cProtocolo=nil, "", cProtocolo)
bMostrarPreview := if(bMostrarPreview=nil, "True", bMostrarPreview)
cMarcaDagua := if(cMarcaDagua=nil, "", cMarcaDagua)
bViaConsumidor := if(bViaConsumidor=nil, "", bViaConsumidor)
bSimplificado := if(bSimplificado=nil, "", bSimplificado)
hResult := DllCall(oDll, DLL_STDCALL, "NFE_Inicializar", hb_StrToUTF8("ACBrLib.Ini"), hb_StrToUTF8(""))
hResult := DllCall(oDll, DLL_STDCALL, "NFE_CarregarXML", hb_StrToUTF8(eArquivoOuXml))
hResult := DllCall(oDll, DLL_STDCALL, "NFE_Imprimir", hb_StrToUTF8(cImpressora), nNumCopias, hb_StrToUTF8(cProtocolo), hb_StrToUTF8(bMostrarPreview), hb_StrToUTF8(cMarcaDagua), hb_StrToUTF8(bViaConsumidor), hb_StrToUTF8(bSimplificado))
if !Empty(hResult)
bufferLen := STR_LEN
buffer := Space(bufferLen)
oErr := DllCall(oDll, DLL_STDCALL, "NFE_UltimoRetorno", @buffer, @bufferLen)
MsgStop(buffer, "Erro: "+Str(hResult))
endif
DllCall(oDll, DLL_STDCALL, "NFE_Finalizar")
DllUnload(oDll)
return nil
static function ImprimirSAT(eArquivoOuXml, cImpressora)
local hResult, bufferLen, buffer, oErr
local oDll := DllLoad( 'ACBrSat32.dll' )
eArquivoOuXml := if(eArquivoOuXml=nil, "acbrsat.xml", eArquivoOuXml)
cImpressora := if(cImpressora=nil, "", cImpressora)
hResult := DllCall(oDll, DLL_STDCALL, "SAT_Inicializar", hb_StrToUTF8("ACBrLib.Ini"), hb_StrToUTF8(""))
hResult := DllCall(oDll, DLL_STDCALL, "SAT_ImprimirExtratoVenda", hb_StrToUTF8(eArquivoOuXml), hb_StrToUTF8(cImpressora))
if !Empty(hResult)
bufferLen := STR_LEN
buffer := Space(bufferLen)
oErr := DllCall(oDll, DLL_STDCALL, "SAT_UltimoRetorno", @buffer, @bufferLen)
MsgStop(buffer, "Erro: "+Str(hResult))
endif
DllCall(oDll, DLL_STDCALL, "SAT_Finalizar")
DllUnload(oDll)
return nil