ActiveDelphi - Índice do Fórum ActiveDelphi
.: O site do programador Delphi! :.
 
 FAQFAQ   PesquisarPesquisar   MembrosMembros   GruposGrupos   RegistrarRegistrar 
 PerfilPerfil   Entrar e ver Mensagens ParticularesEntrar e ver Mensagens Particulares   EntrarEntrar 

Problemas com dll

 
Novo Tópico   Responder Mensagem    ActiveDelphi - Índice do Fórum -> Delphi
Exibir mensagem anterior :: Exibir próxima mensagem  
Autor Mensagem
Cossalter
Novato
Novato


Registrado: Segunda-Feira, 18 de Outubro de 2004
Mensagens: 71

MensagemEnviada: Sex Jul 14, 2006 11:49 am    Assunto: Problemas com dll Responder com Citação

Senhores, vou ter que colocar um form numa dll e estou estudando como fazer isso, porém, meu código funciona bem na 1a vez. Na 2a vez que eu chamo a dll ele trava com a seguinte mensagem:

Project faulted with message: \'access violation at 0x00405929: write of address 0x00030de0\'. Process Stopped. Use Step or Run to continue.

Segue abaixo o meu código:

==> Código a ser incorporado na dll: <==
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TBlablabla = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
Button2: TButton;
private
{ Private declarations }
public
{ Public declarations }
end;

var
Blablabla: TBlablabla;

function GetDados (Dado1: string): string; export;

implementation

{$R *.dfm}
function GetDados (Dado1: string): string;
begin
Blablabla := TBlablabla.Create(Application);
Blablabla.Edit1.Text := Dado1;
try
if Blablabla.ShowModal = mrOk then
Result := Blablabla.Edit1.Text
else
Result := Blablabla.Label1.Caption;
finally
Blablabla.Free;
end;
end;

end.

------------------------------------------------------------------------------------------------

==> Código da dlll: <==
library teste_dll;

uses
Unit1 in \'UNIT1.PAS\' {Blablabla};

{$R *.res}

exports
GetDados index 1;

begin

end.

-----------------------------------------------------------------------------------------
==> Código de chamada: <==

unit Unit2;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

function GetDados (Dado1: string): string;
far; external \'TESTE_DLL\';

procedure TForm1.Button1Click(Sender: TObject);
var
dado1: string;
begin
dado1 := \'Digite aqui!\';
Label1.Caption := GetDados(Dado1);
end;

end.


--------------------------------------------------------------------------
Alguém sabe o que pode estar acontecendo para me dar uma luz? Smile

Abraço!
Voltar ao Topo
Ver o perfil de Usuários Enviar Mensagem Particular
johnny-walker
Moderador
Moderador


Registrado: Sábado, 4 de Outubro de 2003
Mensagens: 10653
Localização: Contagem/MG - BRAZIL

MensagemEnviada: Sex Jul 14, 2006 3:42 pm    Assunto: Problemas com dll Responder com Citação

O seu erro é muito simples...
Você esté utilizando Strings
Mude para Shortstrings ou PChar
ou então utilize DELPHIMM.DLL

você não deve ter notado o texto acima na dll:

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
View-Project 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 DELPHIMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using DELPHIMM.DLL, pass string information
using PChar or ShortString parameters. }

eh soh... bye...

PS.: Ah, é isso que está gerando a violação de acesso...
_________________
P.O.W.E.R B.Y D.E.L.P.H.I


Editado pela última vez por johnny-walker em Qui Out 11, 2018 8:46 am, num total de 1 vez
Voltar ao Topo
Ver o perfil de Usuários Enviar Mensagem Particular MSN Messenger
M2_GIbin
Novato
Novato


Registrado: Terça-Feira, 30 de Mai de 2006
Mensagens: 56

MensagemEnviada: Qua Out 18, 2006 1:28 pm    Assunto: Problemas com dll Responder com Citação

OLA ESTOU COM O MESMO PROBLEMA MAIS O MEU E aCESS VIOLATION AT ADDRESS 00B3387D IN MODULE ´formularios.DLL´ READ OF ADDRESS 0000B729
ISSO ACONTECE QUANDO EXECUTO O FORM E COLOCO UM BUTTON PARA FECHAR A PRIMEIRA VEZ FECHA A SEGUNDA VEZ ELE NEM ABRE O QUE PODE SER PODEM ME AJUDAR
OBRIGADO...
Voltar ao Topo
Ver o perfil de Usuários Enviar Mensagem Particular
Mostrar os tópicos anteriores:   
Novo Tópico   Responder Mensagem    ActiveDelphi - Índice do Fórum -> Delphi Todos os horários são GMT - 3 Horas
Página 1 de 1

 
Ir para:  
Enviar Mensagens Novas: Proibido.
Responder Tópicos Proibido
Editar Mensagens: Proibido.
Excluir Mensagens: Proibido.
Votar em Enquetes: Proibido.


Powered by phpBB © 2001, 2005 phpBB Group
Traduzido por: Suporte phpBB