![]() |
Error al LLamar un DLL, "memoria Insuficiente"
hola a todos.
Tengo una dll que uso para comunicar un dispositivo conectado al puerto COM con un programa ya realizado, la funcion que hace la lectura del puerto funciona perfectamente desde un formulario interno de la misma DLL, pero al hacer el llamado de la funcion de lectura del puerto desde el programa, realiza la funcion de apertura del puerto, la funcion del dispositivo para realizar la transaccion, pero cuando va a leer el puerto sale un mensaje que dice "memoria Insuficiente". estuve viendo con un monitor de puerto que realmente se envia los datos. aqui esta el codigo de la DLL obviamente en DELPHI: procedure Banda;stdcall; var Texto:string; Bytes: DWORD; begin //mensaje de seleccion de llave maestra Texto:= #2 + 'Z1'+ #3 + 'h'+#2 + 'Z9'+'03'+ #3 + 'c'; WriteFile(ComFile, Texto[1], Length(Texto), Bytes, nil); SetProcessWorkingSetSize(GetCurrentProcess, $FFFFFFFF, $FFFFFFFF); end; function leebanda:string;stdcall; var sTmp: string; c1,rebut: integer; chBuffer: array[0..150] of char; NumberOfBytesRead: dword; begin //abro el puerto AbrirPuerto('COM1','1200','E','7','1'); //mensaje de solicitud de lectura del dispositivo banda; //aqui realiza la lectura del puerto repeat rebut:=0; repeat if ComFile=INVALID_HANDLE_VALUE then Exit; if not ReadFile(ComFile, chBuffer[rebut],1, NumberOfBytesRead, nil) then raise Exception.Create('Imposible leer datos desde el puerto'); for c1:= 0 to NumberOfBytesRead - 1 do sTmp:= sTmp+chBuffer[c1]; until rebut<100 ; if chBuffer[rebut]=chr(04) then begin CerrarPuerto; //libero memoria SetProcessWorkingSetSize(GetCurrentProcess, $FFFFFFFF, $FFFFFFFF); break; end; until rebut=100; result:=sTmp; end; y aqui esta el codigo de la aplicacion que usa la DLL y desafortunadamente en ViSUAL: Private Declare Function leebanda Lib "C:\pnp\dllcredicard.dll" () As String Public retorno As String Public x As String 'Leer banda de tarjeta Private Sub boton_leer_banda_Click() Dim txt As String Dim token As String Dim msj As String ' Se llama a la función del VPOS para leer la banda de tarjetas de créditos y débitos retorno = leebanda ' Se obtiene el valor del string que retorna la función del VPOS ' este string posee los valores de los tracks de la tarjeta a la cual se le leyo la banda x = retorno retorno = GetToken(retorno, ";") '& vbCrLf Do token = GetToken("", ";") If token = "" Then Exit Do retorno = retorno '& vbCrLf txt = token Loop ' Se asigna en la box de texto el valor de los diferentes tracks If retorno <> "" Then var = InStr(1, retorno, "?") msj = Mid(retorno, 2, var - 2) txt_track1.Text = msj Else txt_track1.Text = "" End If If txt <> "" Then var = InStr(1, txt, "?") msj = Mid(txt, 1, var - 2) txt_track2.Text = msj Else txt_track2.Text = "" End If End Sub ' Esta función parte el string de acuerdo a un caracter de separación que se le pasa en su invocación Public Function GetToken(new_txt As String, delimiter As String) As String Static txt As String Dim pos As Integer ' Save new text. If new_txt <> "" Then txt = new_txt pos = InStr(txt, delimiter) If pos < 1 Then pos = Len(txt) + 1 GetToken = Left$(txt, pos - 1) pos = Len(txt) - pos + 1 - Len(delimiter) If pos < 1 Then txt = "" Else txt = Right$(txt, pos) End If End Function quisiera saber porque me ocurre este problema. |
La franja horaria es GMT +2. Ahora son las 12:47:50. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi