有关动态连接库的问题(DLL)(50分)

  • 主题发起人 主题发起人 angelwork
  • 开始时间 开始时间
A

angelwork

Unregistered / Unconfirmed
GUEST, unregistred user!
我是第一次学习动态连接库的使用,在使用中发现了一个问题:我试验的开发了一个用于
计算的窗体,其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
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 MaxNum(x,y:integer):integer;stdcall;
begin
if x>y then
result:=x
else
result:=y;
end;

//两个整数求最小值
function MinNum(x,y:integer):integer;stdcall;
begin
if x>y then
result:=y
else
result:=x;
end;

// 两个整数相乘
function MulNum(x,y:integer):integer;stdcall;
begin
result:=x*y;
end;

//两个整数相加
function PlusNum(x,y:integer):integer;stdcall;
begin
result:=x+y;
end;

//两个整数相减
function MinusNum(x,y:integer):integer;stdcall;
begin
result:=x-y;
end;

//导出表
exports
[red] MinNum;[/red]
begin
end.
在Dll接口部分定义出口时,为什么我只能够定义一个接口(MinNum)呢?如果在添加一个
MaxNum就提示错误!请问高手,这样的问题该如何解决呢?谢谢!

 
错误提示是什么??
 
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 MaxNum(x, y: integer): integer; stdcall;
begin
if x > y then
result := x
else
result := y;
end;

//两个整数求最小值

function MinNum(x, y: integer): integer; stdcall;
begin
if x > y then
result := y
else
result := x;
end;

// 两个整数相乘

function MulNum(x, y: integer): integer; stdcall;
begin
result := x * y;
end;

//两个整数相加

function PlusNum(x, y: integer): integer; stdcall;
begin
result := x + y;
end;

//两个整数相减

function MinusNum(x, y: integer): integer; stdcall;
begin
result := x - y;
end;

//导出表
exports
MinNum,
MinusNum,
PlusNum,
MulNum,
MaxNum; //d6下编译通过,没有问题啊?!!你的出错提示是什么?
begin

end.

 
exports
maxnum ,MinNum,mulnum,minusnum;
begin
end.
编译成功,没问题。
 
谢谢各位!特别是shangshang!呵呵,看过shangshang的代码招到问题所在了

那就是 ,(逗号)与;(分号)的问题,呵呵!谢谢各位!
 
shangshang介意加我的QQ吗?

我的QQ:8503462
 
后退
顶部