delphi 简单dll调用出错

library wjfz;

{ 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
shellapi,
ShareMem,
System.SysUtils,
System.Classes;

{$R *.res}

function DelDirectory(X,Y:integer): integer; stdcall;
begin
Result :=X+Y;
end;

exports
DelDirectory;
// DelDirectory12;
begin

end. 这是简单的dll,求和

unit Unit2;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs , shellapi, Vcl.StdCtrls;

type
TForm2 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form2: TForm2;

implementation

{$R *.dfm}
function DelDirectory(X,Y:integer): integer; stdcall; external 'wjfz.dll' ;

procedure TForm2.Button1Click(Sender: TObject);
begin
edit3.Text:=inttostr(DelDirectory(1,2));

end;

end. 用一个按钮实现1+2的和

他就报错! access violation at address......

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐