Ver Mensaje Individual
  #3  
Antiguo 21-10-2004
Avatar de StartKill
StartKill StartKill is offline
Miembro
 
Registrado: ene 2004
Posts: 299
Reputación: 21
StartKill Va por buen camino
Question

Holas,

Utilizo Delphi 7.0 interbase 7.1.
Escribo estas lineas, no para dar respuesa a este hilo si para invocar ayuda a uds.

Original de EITB
Código Delphi [-]
unit Unit1;
interface
function StrMid(pCadena : String; iIndex : Integer ; iNum : integer) : ShortString; cdecl; export;
implementation
function StrMid(pCadena : String; iIndex : Integer ; iNum : integer) : ShortString;
begin
   result := copy(pCadena,iIndex,Inum);
end;
end.

El asunto es que yo para crar una DLL hago siguiente,

Elijo la Opcion <File/New/Other...> alli aparce un folder con muchas pestañas y elijo <New> dentro de esta hay un icono que dice <DLL wizard>.. le hago click

Me aparece el siguiente codigo:
Código Delphi [-]
library Project1;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }

uses
  SysUtils,
  Classes;

{$R *.res}

begin
end.

Teniendo esta estructura procedi a crear mi funcion asi:

Código Delphi [-]
library Project1;

{ ...
   .... }

uses
  SysUtils,
  Classes;

{$R *.res}
Function Suma_01(var XX:Integer):Integer;cdecl;export;
Var
  nUno:Integer;
begin
  nUno:=0;
  Result:=XX+nUno;
end;
end.
Procedi a compilarlo y me resulto <project1.dll> y lo copie a la carpeta BIN de interbase.
Abri mi ibexpert y declare mi funcion asi:
Código SQL [-]
declare external function suma_01 integer returns integer
entry_point 'suma_01' module_name 'project1.dll';
Hasta alli todo parece correcto, pero cuando intento utilizar dicha funcion..
Código SQL [-]
SELECT SUMA_01(FID) AS ID, FDES_AREA FROM AREA
Me envia el siguiente error:
Código:
Invalid token.
invalid request BLR at offset 78.
function SUMA_01 is not defined.
module name or entrypoint could not be found.
Como obsevan primero, la forma de creal la DLL es totalmente diferente a la escrita por nuestro amigo EITB , no estoy utilizando cadenas de caracteres, y el error es diferente, como si no encontrara la funcion....ahora, si no esta la funcion como le hago?, donde estoy fallando?...

Si alguien pudiera detallar la forma de crear funciones definidas por el usuario en delphi les estaremos agradecidos..

Your friend,

StartKill
Lima-Perú
Responder Con Cita