X
xjhuo
Unregistered / Unconfirmed
GUEST, unregistred user!
Library h_dll;//动态链接库
uses
Dialogs,
hhh in 'hhh.pas' {Form1};
function Hobbit(value:integer):string;export;
begin
case value of
1:result:='Frodo';
2:result:='Samwise';
3:result:='Pippin';
4:result:='Meriadoc';
else
result:='Must be an Orc!';
end;
end;
function Larger(Val1,Val2:integer):integer;export;
begin
if Val1>Val2 then
result:=Val1
else
if Val2>Val1 then
result:=Val2
else
result:=0;
end;
procedure Elephants;Export;
begin
ShowMessage('Pink Elephants on Parade');
end;
exports
Hobbit index 1,
Larger index 2,
Elephants index 3;
begin
end.
unit hhh;//是用来调用DLL的程序
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
GroupBox1: TGroupBox;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
function Hobbit(Value:Integer):string;external'MyDll' index 1;
function Larger(val1,val2:integer):integer;external 'MyDll' index 2;
procedure Elephants;external 'MyDll'index 3;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Lines.add(Hobbit(5));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Memo1.Lines.Add (IntToStr(Larger(12,25))+'is larger than 12');
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Elephants;
end;
end.
问题还是:在编译时,它仍然要求我指定宿主程序。而我由于不能正常调用DLL,所以无法生成。EXE文件,因而不能形成该宿主程序!
恳请各位相助!
uses
Dialogs,
hhh in 'hhh.pas' {Form1};
function Hobbit(value:integer):string;export;
begin
case value of
1:result:='Frodo';
2:result:='Samwise';
3:result:='Pippin';
4:result:='Meriadoc';
else
result:='Must be an Orc!';
end;
end;
function Larger(Val1,Val2:integer):integer;export;
begin
if Val1>Val2 then
result:=Val1
else
if Val2>Val1 then
result:=Val2
else
result:=0;
end;
procedure Elephants;Export;
begin
ShowMessage('Pink Elephants on Parade');
end;
exports
Hobbit index 1,
Larger index 2,
Elephants index 3;
begin
end.
unit hhh;//是用来调用DLL的程序
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
GroupBox1: TGroupBox;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
function Hobbit(Value:Integer):string;external'MyDll' index 1;
function Larger(val1,val2:integer):integer;external 'MyDll' index 2;
procedure Elephants;external 'MyDll'index 3;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Lines.add(Hobbit(5));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Memo1.Lines.Add (IntToStr(Larger(12,25))+'is larger than 12');
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Elephants;
end;
end.
问题还是:在编译时,它仍然要求我指定宿主程序。而我由于不能正常调用DLL,所以无法生成。EXE文件,因而不能形成该宿主程序!
恳请各位相助!