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
    关注
    评论

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)