Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Invalid Pointer operation Dll (https://www.clubdelphi.com/foros/showthread.php?t=60831)

mcarazas 15-10-2008 16:55:12

Invalid Pointer operation Dll
 
Hola amigos del foro, tengo problemas al poder trabajar con funciones de otra Dll, tengo esta aplicacion de prueba donde esta funcion "funcReemp" la extraigo de la Dll DataDll.dll, al momento de hacer funcionar mi aplicacion y utilizo la funcion me sale este error "Invalid Pointer operation". Estoy colocando el codigo de mi aplicacion y de mi Dll por favor espero puedan ayudarme. Un saludo

codigo de la aplicacion:
Código Delphi [-]

unit prueba;  interface  uses   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,   Dialogs, StdCtrls;  
type   
TForm1 = class(TForm)     Edit1: TEdit;     Button1: TButton;     procedure 
Button1Click(Sender: TObject);   private     { Private declarations }   public      { Public declarations }   end;  var   Form1: TForm1;  

implementation {$R *.dfm} 

function funcReemp (cad: String): String; external 'DataDll.dll';   

procedure TForm1.Button1Click(Sender: TObject); 
begin   
Edit1.Text := funcReemp('121.12');   
end;

codigo Dll:

Código Delphi [-]
library DataDll;  uses   SysUtils,   Classes,   Forms,   ADODB,   Grids,   StdCtrls,   Dialogs,   Controls,   Windows,   RpCon,   RpConDS,   RpDefine,   RpRave,   RpBase,   RpSystem,   ImgList,   StdActns,   ActnList,   AppEvnts,   ExtCtrls,   Messages,   Menus,   RpRender,   RpRenderPDF,   Math,   Graphics,   XPStyleActnCtrls,   ActnMan,   StrUtils;  {$R *.res}  type   TMatriz = Array [0..100, 0..100]of String;   
function funcReemp (cad: String): String; 
var aux: Integer; 
begin   
cad:= FloatToStr (RoundTo (StrToFloat (cad), -2));   
aux:= PosEx (',', cad, 1);   if aux <> 0 then     
funcReemp:= StuffString (cad, aux, 1, '.')   
else     
funcReemp := '0'; end;  exports funcReemp; 
end.

seoane 15-10-2008 20:49:01

Aqui te dejo un poco de lectura:
Cita:

Empezado por La ayuda de Delphi
Shared-Memory Manager (Win32 Only)
On Win32, if a DLL exports routines that pass long strings or dynamic arrays as parameters or function results (whether directly or nested in records or objects), then the DLL and its client applications (or DLLs) must all use the ShareMem unit. The same is true if one application or DLL allocates memory with New or GetMem which is deallocated by a call to Dispose or FreeMem in another module. ShareMem should always be the first unit listed in any program or library uses clause where it occurs.


cHackAll 15-10-2008 21:45:14

Aqui te dejo otra información que considero debes analizar.

Saludos


La franja horaria es GMT +2. Ahora son las 11:10:20.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi