Problema na criação de DLLs (Urgente)
12/07/2008
0
Obrigado a todos e aguardo qualquer orientação.
Aprendiz_ce
Posts
12/07/2008
Luiz Henrique
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+
12/07/2008
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.
12/07/2008
Aprendiz_ce
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.
14/07/2008
Luiz Henrique
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+
14/07/2008
Aprendiz_ce
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.
16/07/2008
Psyjacko
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
16/07/2008
Aprendiz_ce
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.
Clique aqui para fazer login e interagir na Comunidade :)