Error 9027
Publicado: Lun Abr 20, 2009 12:44 am
Alquien sabe porque aparece este error y como evitarlo ?, aparece
mientras llamo a unas funciones en C, aqui esta el codigo
*----------------------------------------------------------- -------------------*
function Envia(cData,nTopeReint,oForm)
*----------------------------------------------------------- -------------------*
static oFormMain
local cRet:='', nPos, cComando, cTextOld, nRet, k, i, cAux, cRest, nH
DEFAULT nTopeReint TO 30
if valtype(oForm)=='O'
return NIL
endif
nPos :=at(pCF_FIN,cData)
cComando :=substr(cData,3,nPos-3)
nRet:=MandaPaquete( nHandle,cComando )
DELAY10
/// aqui aparece ///
cAux:=Respuesta(nHandle)
cRet:=''
for i:=1 to len(cAux)
cRet+=substr(cAux,i,1)
next
return(cRet)
#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"
HINSTANCE HB_DllStore[256];
typedef int (CALLBACK *puntOPENCOM)(int nCom, int nMode);
typedef int (CALLBACK *puntMANDAPAQ)(int nHandler, LPTSTR pMensaje);
typedef int (CALLBACK *puntRESPUESTA)(int nHandler, LPTSTR pMensaje);
void HB_UnloadDll (void)
{
register int i;
for(i=255;i>=0;i--)
{
FreeLibrary(HB_DllStore);
}
}
HINSTANCE HB_LoadDll (char *DllName)
{
static int DllCnt;
static int RegUnload;
if (!RegUnload) RegUnload=!atexit(HB_UnloadDll);
DllCnt=(DllCnt+1) & 255;
FreeLibrary(HB_DllStore[DllCnt]);
return HB_DllStore[DllCnt]=LoadLibrary(DllName);
}
HB_FUNC( OPENPORT )
{
int nCom = hb_parni( 1 );
int nMode = hb_parni( 2 );
int result = -2000;
char buff[256];
HINSTANCE hInst;
puntOPENCOM lpAddr;
hInst=GetModuleHandle("WinFis32.dll");
if(hInst==NULL)
{
hInst=HB_LoadDll("WinFis32.dll");
}
lpAddr=(puntOPENCOM)GetProcAddress(hInst,"OpenComFiscal");
if(lpAddr==NULL)
{
lpAddr=(puntOPENCOM)GetProcAddress(hInst,buff);
}
if (lpAddr)
{
result = (int)(lpAddr)(nCom,nMode);
}
hb_retni(result);
}
HB_FUNC( MANDAPAQUETE )
{
int nHandler = hb_parni( 1 );
int result = -2000;
LPTSTR pMensaje = hb_parc( 2 );
char buff[256];
HINSTANCE hInst;
puntMANDAPAQ lpAddr;
hInst=GetModuleHandle("WinFis32.dll");
if(hInst==NULL)
{
hInst=HB_LoadDll("WinFis32.dll");
}
lpAddr=(puntMANDAPAQ)GetProcAddress(hInst,"MandaPaqueteFiscal ");
if(lpAddr==NULL)
{
lpAddr=(puntMANDAPAQ)GetProcAddress(hInst,buff);
}
if (lpAddr)
{
result = (int)(lpAddr)(nHandler,pMensaje);
}
hb_retni(result);
}
HB_FUNC( RESPUESTA )
{
int nHandler = hb_parni( 1 );
LPTSTR pBuffer;
char buff[256];
HINSTANCE hInst;
puntRESPUESTA lpAddr;
hInst=GetModuleHandle("WinFis32.dll");
if(hInst==NULL)
{
hInst=HB_LoadDll("WinFis32.dll");
}
lpAddr=(puntRESPUESTA)GetProcAddress(hInst,"UltimaRespuesta ");
if(lpAddr==NULL)
{
lpAddr=(puntRESPUESTA)GetProcAddress(hInst,buff);
}
if (lpAddr)
{
(lpAddr)(nHandler,pBuffer);
hb_retc(pBuffer);
}
}
#pragma ENDDUMP
--
mientras llamo a unas funciones en C, aqui esta el codigo
*----------------------------------------------------------- -------------------*
function Envia(cData,nTopeReint,oForm)
*----------------------------------------------------------- -------------------*
static oFormMain
local cRet:='', nPos, cComando, cTextOld, nRet, k, i, cAux, cRest, nH
DEFAULT nTopeReint TO 30
if valtype(oForm)=='O'
return NIL
endif
nPos :=at(pCF_FIN,cData)
cComando :=substr(cData,3,nPos-3)
nRet:=MandaPaquete( nHandle,cComando )
DELAY10
/// aqui aparece ///
cAux:=Respuesta(nHandle)
cRet:=''
for i:=1 to len(cAux)
cRet+=substr(cAux,i,1)
next
return(cRet)
#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"
HINSTANCE HB_DllStore[256];
typedef int (CALLBACK *puntOPENCOM)(int nCom, int nMode);
typedef int (CALLBACK *puntMANDAPAQ)(int nHandler, LPTSTR pMensaje);
typedef int (CALLBACK *puntRESPUESTA)(int nHandler, LPTSTR pMensaje);
void HB_UnloadDll (void)
{
register int i;
for(i=255;i>=0;i--)
{
FreeLibrary(HB_DllStore);
}
}
HINSTANCE HB_LoadDll (char *DllName)
{
static int DllCnt;
static int RegUnload;
if (!RegUnload) RegUnload=!atexit(HB_UnloadDll);
DllCnt=(DllCnt+1) & 255;
FreeLibrary(HB_DllStore[DllCnt]);
return HB_DllStore[DllCnt]=LoadLibrary(DllName);
}
HB_FUNC( OPENPORT )
{
int nCom = hb_parni( 1 );
int nMode = hb_parni( 2 );
int result = -2000;
char buff[256];
HINSTANCE hInst;
puntOPENCOM lpAddr;
hInst=GetModuleHandle("WinFis32.dll");
if(hInst==NULL)
{
hInst=HB_LoadDll("WinFis32.dll");
}
lpAddr=(puntOPENCOM)GetProcAddress(hInst,"OpenComFiscal");
if(lpAddr==NULL)
{
lpAddr=(puntOPENCOM)GetProcAddress(hInst,buff);
}
if (lpAddr)
{
result = (int)(lpAddr)(nCom,nMode);
}
hb_retni(result);
}
HB_FUNC( MANDAPAQUETE )
{
int nHandler = hb_parni( 1 );
int result = -2000;
LPTSTR pMensaje = hb_parc( 2 );
char buff[256];
HINSTANCE hInst;
puntMANDAPAQ lpAddr;
hInst=GetModuleHandle("WinFis32.dll");
if(hInst==NULL)
{
hInst=HB_LoadDll("WinFis32.dll");
}
lpAddr=(puntMANDAPAQ)GetProcAddress(hInst,"MandaPaqueteFiscal ");
if(lpAddr==NULL)
{
lpAddr=(puntMANDAPAQ)GetProcAddress(hInst,buff);
}
if (lpAddr)
{
result = (int)(lpAddr)(nHandler,pMensaje);
}
hb_retni(result);
}
HB_FUNC( RESPUESTA )
{
int nHandler = hb_parni( 1 );
LPTSTR pBuffer;
char buff[256];
HINSTANCE hInst;
puntRESPUESTA lpAddr;
hInst=GetModuleHandle("WinFis32.dll");
if(hInst==NULL)
{
hInst=HB_LoadDll("WinFis32.dll");
}
lpAddr=(puntRESPUESTA)GetProcAddress(hInst,"UltimaRespuesta ");
if(lpAddr==NULL)
{
lpAddr=(puntRESPUESTA)GetProcAddress(hInst,buff);
}
if (lpAddr)
{
(lpAddr)(nHandler,pBuffer);
hb_retc(pBuffer);
}
}
#pragma ENDDUMP
--