Problema na criação de DLLs (Urgente)
Estou tentando criar uma DLL com o Delphi 7. O problema é que para toda DLL que eu crio nenhuma funciona. Sendo mais claro: No ato do desenvolvimento fica tudo certinho, mas quando vou utilizada a mesma não funciona, daí quando vou ´debugar´ colocando um ´breakpoint´, apesar da linha estar correta, o ´breakpoint´ aponta como se fosse uma linha errada. O que pode ser isso? Como posso resolver esse problema? Faz tempo que ´bato-cabeça´ e não consigo resolver. Cheguei ao ponto de FORMATAR a máquina e instalar somente o Windows XP, Delphi 7, Interbase e o Office XP. Não coloquei mais nada. Tudo não tentativa de descartar qualquer falha de sistema.
Obrigado a todos e aguardo qualquer orientação.
Obrigado a todos e aguardo qualquer orientação.
Aprendiz_ce
Curtidas 0
Respostas
Luiz Henrique
12/07/2008
Bom dia Aprendiz_ce
Possuo algumas DLL´s em funcionamento, de todo tipo e de varios objetivos, todas funcionam bem, pois o Delphi posso te assegurar que nao tem problema quanto a isso. Se vc nos disser o erro que da e postar a tua DLL aqui, poderemos te ajudar.
Abraço , T+
Possuo algumas DLL´s em funcionamento, de todo tipo e de varios objetivos, todas funcionam bem, pois o Delphi posso te assegurar que nao tem problema quanto a isso. Se vc nos disser o erro que da e postar a tua DLL aqui, poderemos te ajudar.
Abraço , T+
GOSTEI 0
Aprendiz_ce
12/07/2008
[quote:80addcbcde=´Luiz Henrique´]Bom dia Aprendiz_ce
Possuo algumas DLL´s em funcionamento, de todo tipo e de varios objetivos, todas funcionam bem, pois o Delphi posso te assegurar que nao tem problema quanto a isso. Se vc nos disser o erro que da e postar a tua DLL aqui, poderemos te ajudar.
Abraço , T+[/quote:80addcbcde]
Olá,
Também concordo com você quanto ao Delphi... Daí a minha surpresa!
Vou passar um código bem simples que testei por ultimo, mas que não consigo fazer funcionar.
Segue abaixo:
program Project1;
uses
Forms,
Unit1 in ´Unit1.pas´ ;
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function Max(a, b : double):double;stdcall;
var
Form1: TForm1;
implementation
{$R *.dfm}
function Max(a, b : double):double;external ´project1´;
procedure TForm1.Button1Click(Sender: TObject);
var
x, y, resultado : double;
begin
x := StrToFloat(Edit1.Text);
y := StrToFloat(Edit2.Text);
resultado := Max(x,y);
ShowMessage(´Valor Máximo ´ +FloatToStr(resultado));
end;
end.
Quando tento utiliza-la a segunte mendagem é retornada:
Aplicativo não inicializado corretamente (0xc000007b). Clique em ´OK´ para finalizar e execução.
Obs. Tanto faz quando a mesma é carregada por outro programa ou quando tento depura-la sem ´breakpoint´... Se coloco um ´breakpoint´ mesmo que veja bem no inicio de um eventos... É apontado como erro (sinal de ´x´ em vermelho).
E aí, o que pode ser? Estou preocupado, pois minha cabeça pode rolar...
Muito obrigado pela sua atenção e aguardo retorno.
Abraço.
Possuo algumas DLL´s em funcionamento, de todo tipo e de varios objetivos, todas funcionam bem, pois o Delphi posso te assegurar que nao tem problema quanto a isso. Se vc nos disser o erro que da e postar a tua DLL aqui, poderemos te ajudar.
Abraço , T+[/quote:80addcbcde]
Olá,
Também concordo com você quanto ao Delphi... Daí a minha surpresa!
Vou passar um código bem simples que testei por ultimo, mas que não consigo fazer funcionar.
Segue abaixo:
program Project1;
uses
Forms,
Unit1 in ´Unit1.pas´ ;
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function Max(a, b : double):double;stdcall;
var
Form1: TForm1;
implementation
{$R *.dfm}
function Max(a, b : double):double;external ´project1´;
procedure TForm1.Button1Click(Sender: TObject);
var
x, y, resultado : double;
begin
x := StrToFloat(Edit1.Text);
y := StrToFloat(Edit2.Text);
resultado := Max(x,y);
ShowMessage(´Valor Máximo ´ +FloatToStr(resultado));
end;
end.
Quando tento utiliza-la a segunte mendagem é retornada:
Aplicativo não inicializado corretamente (0xc000007b). Clique em ´OK´ para finalizar e execução.
Obs. Tanto faz quando a mesma é carregada por outro programa ou quando tento depura-la sem ´breakpoint´... Se coloco um ´breakpoint´ mesmo que veja bem no inicio de um eventos... É apontado como erro (sinal de ´x´ em vermelho).
E aí, o que pode ser? Estou preocupado, pois minha cabeça pode rolar...
Muito obrigado pela sua atenção e aguardo retorno.
Abraço.
GOSTEI 0
Aprendiz_ce
12/07/2008
Faltou o principal...
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}
Function Max(a, b : double ) : double ; Export ; stdcall ;
begin
If (a > b) then
Result := a
else
Result := b ;
end ;
begin
end.
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}
Function Max(a, b : double ) : double ; Export ; stdcall ;
begin
If (a > b) then
Result := a
else
Result := b ;
end ;
begin
end.
GOSTEI 0
Niubi
12/07/2008
Me parece que em sua api faltou vc exportar sua função.
GOSTEI 0
Luiz Henrique
12/07/2008
Blz aprendiz...
faça estes ajustes que vai funcionar:
Na dll.
...
{$R *.res}
Function Max(a, b : double ) : double ; stdcall ;
begin
If (a > b) then
Result := a
else
Result := b ;
end;
exports Max;
end.
...na execucao...somente esta declaracao...
{$R *.dfm}
function Max(a, b : double):double; stdcall; external ´project1´;
...blz, espero que ajude, t+
faça estes ajustes que vai funcionar:
Na dll.
...
{$R *.res}
Function Max(a, b : double ) : double ; stdcall ;
begin
If (a > b) then
Result := a
else
Result := b ;
end;
exports Max;
end.
...na execucao...somente esta declaracao...
{$R *.dfm}
function Max(a, b : double):double; stdcall; external ´project1´;
...blz, espero que ajude, t+
GOSTEI 0
Aprendiz_ce
12/07/2008
[quote:313efd319f=´Luiz Henrique´]Blz aprendiz...
faça estes ajustes que vai funcionar:
Na dll.
...
{$R *.res}
Function Max(a, b : double ) : double ; stdcall ;
begin
If (a > b) then
Result := a
else
Result := b ;
end;
exports Max;
end.
...na execucao...somente esta declaracao...
{$R *.dfm}
function Max(a, b : double):double; stdcall; external ´project1´;
...blz, espero que ajude, t+[/quote:313efd319f]
OK!
Obrigado pela sua atenção.
faça estes ajustes que vai funcionar:
Na dll.
...
{$R *.res}
Function Max(a, b : double ) : double ; stdcall ;
begin
If (a > b) then
Result := a
else
Result := b ;
end;
exports Max;
end.
...na execucao...somente esta declaracao...
{$R *.dfm}
function Max(a, b : double):double; stdcall; external ´project1´;
...blz, espero que ajude, t+[/quote:313efd319f]
OK!
Obrigado pela sua atenção.
GOSTEI 0
Psyjacko
12/07/2008
essa linha
flw , abraços
{$R *.res}
vc remove da DLL e detalhe tem que botar no exports o nome da Function e o Index dela na função , exemplo :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; Function Soma(a,b:Integer):Integer;export;stdcall; begin Result := a + b; end; // Function Subtracao(a,b:Integer):Integer;export;stdcall; begin Result := a - b; end; exports soma index 1; Subtracao index 2; begin end.
flw , abraços
GOSTEI 0
Aprendiz_ce
12/07/2008
essa linha [quote:50c8103700]{$R *.res}
vc remove da DLL e detalhe tem que botar no exports o nome da Function e o Index dela na função , exemplo :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; Function Soma(a,b:Integer):Integer;export;stdcall; begin Result := a + b; end; // Function Subtracao(a,b:Integer):Integer;export;stdcall; begin Result := a - b; end; exports soma index 1; Subtracao index 2; begin end.
flw , abraços[/quote:50c8103700]
Beleza!!!
Obrigado pela sua atenção.
Abraço.
GOSTEI 0