Página 1 de 1

Error 9027

Publicado: Lun Abr 20, 2009 12:44 am
por Christian
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
--

Error 9027

Publicado: Mar Abr 21, 2009 1:06 pm
por jfgimenez
Christian,
> Alquien sabe porque aparece este error y como evitarlo ?, aparece
> mientras llamo a unas funciones en C, aqui esta el codigo
Ese mensaje significa exactamente lo que dice, es decir, que se está
accediendo a una cadena que ya ha sido liberada (eliminada de la memoria).
No sé si será el caso, pero asegúrate de si esas funciones de la dll son
síncronas o asíncronas. Si son asíncronas, entonces es muy posible que los
problemas vengan de ahí. Y si no, me temo que tendrás que revisar muy a
fondo las rutinas en C.
--
Un saludo,
José F. Giménez
http://www.xailer.com
http://www.xailer.info

Error 9027

Publicado: Mar Abr 21, 2009 1:33 pm
por Christian
Gracias por la respuesta Jose F., voy a revisar las funciones en C y son
funciones asincronas.
Jose F. Gimenez escribió:
> Christian,
>
>> Alquien sabe porque aparece este error y como evitarlo ?, aparece
>> mientras llamo a unas funciones en C, aqui esta el codigo
>
> Ese mensaje significa exactamente lo que dice, es decir, que se está
> accediendo a una cadena que ya ha sido liberada (eliminada de la memoria).
> No sé si será el caso, pero asegúrate de si esas funciones de la dll son
> sí­ncronas o así­ncronas. Si son así­ncronas, entonces es muy posible que los
> problemas vengan de ahí­. Y si no, me temo que tendrás que revisar muy a
> fondo las rutinas en C.
>
>