Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 16-06-2013
webmasterplc webmasterplc is offline
Miembro
 
Registrado: mar 2008
Posts: 274
Poder: 17
webmasterplc Va por buen camino
Error al Llamar Función en DLL (Interface not suported).

Buenas, estoy escribiendo una función para enviar datos post a un gateway de sms, ya hice la función y todo perfecto, pero ahora me gustaría tenerla en dll la paso a dll pero me dice Interface Not Suported, aqui dejo el codigo de la dll y la llamada.

Codigo DLL.

Código Delphi [-]
library sms;

{ 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,
  IdHTTP;

{$R *.res}
function enviarSMS (url,usuario,clave,phone,mensaje : string) : string; export
var
  http: TIdHttp;
  params: TStrings;
  respuesta: string;
begin
    http := TIdHTTP.Create(nil);
    params := TStringList.Create;

    begin
        params.Add('usuario='+usuario);
        params.Add('clave='+clave);
        params.Add('telefonos='+phone);
        params.Add('texto='+mensaje);
        respuesta := http.Post(url, params);
    end;
    params.Free;
    http.Free;
end;
end.

este es el de la llamada

Código Delphi [-]
var
Form1: TForm1;
function enviarSMS (url,usuario,clave,phone,mensaje : string) : string; stdcall external'sms.dll';
implementation

{$R *.dfm}

procedure TForm1.btn1Click(Sender: TObject);
begin
enviarSMS(edt1.Text,edt2.Text,edt3.Text,edt4.Text,edt5.Text);
edt4.Clear;
edt5.Clear;
end;
Responder Con Cita
  #2  
Antiguo 16-06-2013
beginner01 beginner01 is offline
Miembro
NULL
 
Registrado: mar 2011
Ubicación: República Dominicana
Posts: 181
Poder: 14
beginner01 Va por buen camino
Hola.

Es bueno especificar que versión de delphi usas.

Yo realicé una prueba con tu código en Delphi xe y lo primero es que no vi el error que comentas, pero lo primero que te puedo sugerir es que agregues la función a ejecutar desde fuera de la dll en una sección exports.


Código Delphi [-]
library sms;

{ 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,
  IdHTTP;

{$R *.res}
function enviarSMS (url,usuario,clave,phone,mensaje : string) : string;
var
  http: TIdHttp;
  params: TStrings;
  respuesta: string;
begin
    http := TIdHTTP.Create(nil);
    params := TStringList.Create;

    begin
        params.Add('usuario='+usuario);
        params.Add('clave='+clave);
        params.Add('telefonos='+phone);
        params.Add('texto='+mensaje);
        respuesta := http.Post(url, params);
    end;
    params.Free;
    http.Free;
end;

exports 
 enviarSMS;


end.
Responder Con Cita
  #3  
Antiguo 16-06-2013
beginner01 beginner01 is offline
Miembro
NULL
 
Registrado: mar 2011
Ubicación: República Dominicana
Posts: 181
Poder: 14
beginner01 Va por buen camino
Post

Hola.

Te dejo un enlace que te puede servir de mucha ayuda, está en ingles, pero contiene una buena información de como realizar las
llamadas a las funciones contenidas en dll y las precauciones.

Calling Conventions.

Te sugiero, que te fijes en en el demo al final de la página del enlace.
Responder Con Cita
  #4  
Antiguo 16-06-2013
webmasterplc webmasterplc is offline
Miembro
 
Registrado: mar 2008
Posts: 274
Poder: 17
webmasterplc Va por buen camino
Uso delphi 7, voy a probar lo que me dices y les comento
Responder Con Cita
  #5  
Antiguo 17-06-2013
webmasterplc webmasterplc is offline
Miembro
 
Registrado: mar 2008
Posts: 274
Poder: 17
webmasterplc Va por buen camino
Gracias Funciona bien saludos
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Llamar funcion dll con una cadena... robinsongm Varios 6 26-02-2010 20:55:21
Llamar a una función de una DLL desde PHP MON___ Varios 4 05-10-2007 23:06:48
Llamar de una función a otra jorgegetafe Varios 6 05-06-2007 15:53:19
¿Como llamar una funcion de una DLL? paty_rlopez Varios 3 26-06-2006 15:25:25
problema al llamar una función sgarrido Varios 3 27-07-2004 01:14:33


La franja horaria es GMT +2. Ahora son las 11:58:30.


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
Copyright 1996-2007 Club Delphi