liuruijin 发表于 2019-5-17 20:23:22

新手求助dll文件按照小甲鱼老师的教的写的,还是报错,请大神给看看

library Project2;

{ 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(x,y,z:integer):integer;StdCall;
var
t: integer;
begin
if(x<y) then
t:=y
else
t:=x;

if(t<z) then
t:=z
else
max:=t;
end;

Function min(x,y,z:integer):integer;StdCall;
var
t: integer;
begin
if(x>y) then
t:=y
else
t:=x;
if(t>z) then
t:=z
else
min:=t;
end;
exports
max,min;
begin
end.

liuruijin 发表于 2019-5-17 20:28:08

老提示value assigned to 't' never used   return value of function 'max'might be undefined;

ba21 发表于 2019-5-17 21:53:50

2个提示而已。不过话说,这是你自己写的代码吧。不要把责任推给小甲鱼老师。
一个函数要在任何时候都有返回值。比如说你这个
Function max(x,y,z:integer):integer;StdCall;
var
t: integer;
begin
if x<ythen
    t:=y
else
    t:=x;

if t<zthen
    t:=z;

max:=t;
end;

对比下,你的函数保证能在任何情况下都有返回值吗?

cplus 发表于 2019-8-7 14:24:35

{:10_256:}

cplus 发表于 2019-8-17 18:27:04

你好,楼主,问题解决了,请结帖!
页: [1]
查看完整版本: 新手求助dll文件按照小甲鱼老师的教的写的,还是报错,请大神给看看