.子程序 _临时子程序
本名称子程序用作测试程序用,仅在开发及调试环境中有效,编译发布程序前将被系统自动清空,请将所有用作测试的临时代码放在本子程序中。 ***注意不要修改本子程序的名称、参数及返回值类型。
说明你没去看说明,你的代码要放在新建的子程序中。
//创建DLLlibrary test
uses
dialogs,
SysUtils,
Classes
{$R *.res}
function My_Max(a,b:integer):integerstdcall
begin
if (a >b) then
result := a
else
result := b
end
exports My_Max
begin
end.
//调用开始
unit Unit11
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,stdctrls
type
TForm1 = class(TForm)
Button1: TButton
procedure Button1Click(Sender: TObject)
private
{ Private declarations }
public
{ Public declarations }
end
var
Form1: TForm1
implementation
{$R *.dfm}
function My_Max(a,b:integer):integerstdcall
external 'E:\mypro\1019(3)\test.dll'
procedure TForm1.Button1Click(Sender: TObject)
begin
showmessage(inttostr(my_max(25,10)))
end
end.
调用时注意DLL里的函数是区别大小写的,这点和DELPHI里的函数不太一样,如果调用的和DLL里的不一致,会报一个无法定位程序输入点的错误。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)