第一次编DLL文件,编译通过,但运行时出现如下提示:
access violation at 0x00000000 address:read of addresss 0x00000000.process
stoped.use step or run to continue.
源程序如下,Project1.dll和调用工程Project12.dpr是放在同一目录下。
library Project1;uses
SysUtils,
Classes,
Unit1 in 'Unit1.pas';exports
addexam;{$R *.res}begin
end.
////////////////////////////////////////////////////
unit Unit1;
interface
function addexam(a:integer;b:integer):integer;export;implementationfunction addexam(a:integer;b:integer):integer;
var
c:integer;
begin
c:=a+b;
result:=c;
end;
end./////////////////////////////////////////////////////////////
unit Unit12;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;function addexam(a:integer;b:integer):integer;stdcall;external'Project1.dll';implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
d,e,f:integer;
begin
d:=1;
e:=3;
f:=addexam(d,e);
label1.Caption:=inttostr(f);
end;end.
access violation at 0x00000000 address:read of addresss 0x00000000.process
stoped.use step or run to continue.
源程序如下,Project1.dll和调用工程Project12.dpr是放在同一目录下。
library Project1;uses
SysUtils,
Classes,
Unit1 in 'Unit1.pas';exports
addexam;{$R *.res}begin
end.
////////////////////////////////////////////////////
unit Unit1;
interface
function addexam(a:integer;b:integer):integer;export;implementationfunction addexam(a:integer;b:integer):integer;
var
c:integer;
begin
c:=a+b;
result:=c;
end;
end./////////////////////////////////////////////////////////////
unit Unit12;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;function addexam(a:integer;b:integer):integer;stdcall;external'Project1.dll';implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
d,e,f:integer;
begin
d:=1;
e:=3;
f:=addexam(d,e);
label1.Caption:=inttostr(f);
end;end.
解决方案 »
- 请各位前辈看看我这段DLL远程注入哪出了问题
- delphi编译错误求助
- ********没有那位英雄知道吗???,rbuilder的问题呀,狂郁闷***************
- 如何取得当前数据库的大小啊???
- Dll 返回 TDataSet 问题续?
- 请大家帮忙,我现在需要作一个程序,功能是把CSV文件导入MSSQL数据库.工具是Delphi+MSSQL.这个星期要完成.我现在不知道怎样下手?请大家帮忙
- 帮忙看一下类的问题
- 在各位师父的帮助下,偶的通讯录已经写好,师父门如有时间的话,帮偶测试一下,好吗?(特别感谢老千,老鱼,chechy,小昂)
- 装sql2000后,电脑速度明显慢了起来,而且说虚拟内存不够?
- 多态与抽象方法(不明白)
- 怎么写一个函数将BCD转整数?
- 怎么样定义一个常量的二维数组?
unit Unit1;
interface
function addexam(a:integer;b:integer):integer;stdcall;export; //加上“stdcall”指示,两边的声明要一样~~implementationfunction addexam(a:integer;b:integer):integer;
var
c:integer;
begin
c:=a+b;
result:=c;
end;
end./////////////////////////////////////////////////////////////