PDA

Ver la Versión Completa : Invalid Pointer operation Dll


mcarazas
15-10-2008, 16:55:12
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:


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:


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:

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 (http://www.clubdelphi.com/foros/guiaestilo.php#nadie) te dejo otra información que considero (http://www.clubdelphi.com/foros/showthread.php?t=60828) debes analizar.

Saludos