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 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献