qq_34656542 2017-07-26 07:29 采纳率: 0%
浏览 826

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条回答 默认 最新

  • threenewbee 2017-07-26 16:06
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题