Dll´s
oi pessoal,
tenho uma dll com varias funções,
como faço para assossiar a dll com o meu programa, e tb,
como0 faço para usar as funções que estão dentro da DLL.
Se a DLL for feita em C tem algum problema de eu usar uma função dela no Delphi?
tenho uma dll com varias funções,
como faço para assossiar a dll com o meu programa, e tb,
como0 faço para usar as funções que estão dentro da DLL.
Se a DLL for feita em C tem algum problema de eu usar uma função dela no Delphi?
Smaug_84
Curtidas 0
Respostas
Beppe
06/10/2003
Você importa uma função de uma dll assim:
Você tb deve usar a msm cc. e. g. stdcall, cdecl, etc...
É importante adicionar ShareMem na uses do projeto, antes das outras, quando você usar strings, variants ou interfaces.
Se vc tiver uma dll escrita em outra linguagem, você precisa os tipos equivalentes em Delphi.
function MinhaFuncao(Param1, Param2: Integer): Integer name ´NomeExportadoParaAFuncao´ external ´minhadll.dll´;
Você tb deve usar a msm cc. e. g. stdcall, cdecl, etc...
É importante adicionar ShareMem na uses do projeto, antes das outras, quando você usar strings, variants ou interfaces.
Se vc tiver uma dll escrita em outra linguagem, você precisa os tipos equivalentes em Delphi.
C++ | Delphi int Integer char Char bool Boolean char* PChar
GOSTEI 0
Smaug_84
06/10/2003
legal, mais e como eu rio uma dll,
tentei criar mais nem tava compilando
library Project2;
uses
SysUtils,
Classes;
{$R *.res}
function teste : PChar;
begin
Result := ´ola mundo´;
end;
begin
end.
tentei criar mais nem tava compilando
library Project2;
uses
SysUtils,
Classes;
{$R *.res}
function teste : PChar;
begin
Result := ´ola mundo´;
end;
begin
end.
GOSTEI 0
Eric.miranda
06/10/2003
Tente assim
library Project2;
uses
SysUtils,
Classes;
{$R *.res}
function teste : PChar;export;stdcall;
begin
Result := ´ola mundo´;
end;
exports
teste;
begin
end.
library Project2;
uses
SysUtils,
Classes;
{$R *.res}
function teste : PChar;export;stdcall;
begin
Result := ´ola mundo´;
end;
exports
teste;
begin
end.
GOSTEI 0
Beppe
06/10/2003
Qual o erro?
GOSTEI 0
Smaug_84
06/10/2003
ta dando pau na chamada da dll no meu programa
expected ´;´ but an identifier found
nao sei oq é?
minha DLL
-------------------------------------------------------------------------
library Project2;
uses
SysUtils,
Classes;
{$R *.res}
function teste : PChar;export;stdcall;
begin
Result := ´ola mundo´;
end;
exports
teste;
begin
end.
meu programa
---------------------------------------------------------------------
unit Unit1;
interface
uses
ShareMem, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls ;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
function t : Pchar name ´teste´ external ´project1.dll´;// name ´teste´;
//function OpenFile: Integer; cdecl; external ´libc.so.6´ name ´open´;
//function printf(Format: PChar): Intege0r; cdecl; varargs;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
t;
end;
end.
expected ´;´ but an identifier found
nao sei oq é?
minha DLL
-------------------------------------------------------------------------
library Project2;
uses
SysUtils,
Classes;
{$R *.res}
function teste : PChar;export;stdcall;
begin
Result := ´ola mundo´;
end;
exports
teste;
begin
end.
meu programa
---------------------------------------------------------------------
unit Unit1;
interface
uses
ShareMem, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls ;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
function t : Pchar name ´teste´ external ´project1.dll´;// name ´teste´;
//function OpenFile: Integer; cdecl; external ´libc.so.6´ name ´open´;
//function printf(Format: PChar): Intege0r; cdecl; varargs;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
t;
end;
end.
GOSTEI 0
Beppe
06/10/2003
Em qual linha? Na dll ou no programa?
GOSTEI 0
Beppe
06/10/2003
Para importar uma função, ela precisa ser global. Vc estava tentando usar com um método... Tire a decl. de interface do TForm1
GOSTEI 0