G
gst
Unregistered / Unconfirmed
GUEST, unregistred user!
调用DLL中的FORM时,系统提示access violation at adress in module 'about.dll',read of adress (100分)<br />-------DLL单元如下
library about;
uses
SysUtils,
Classes,
aboutunit in 'aboutunit.pas' {AboutDllForm};
{$R *.RES}
exports AboutDllFormCreate;
begin
end.
--------ABOUTUNIT单元如下:
unit aboutunit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TAboutDllForm = class(TForm)
Bevel1: TBevel;
Image1: TImage;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormPaint(Sender: TObject);
private
{ Private declarations }
step:integer;
public
{ Public declarations }
end;
var
AboutDllForm: TAboutDllForm;
function AboutDllFormCreate:integer; stdcall;
implementation
{$R *.DFM}
function AboutDllFormCreate:integer; stdcall;
begin
showmessage('hello');
AboutDllForm:=TAboutDllForm.Create(Application);
AboutDllForm.ShowModal;
end;
procedure TAboutDllForm.Timer1Timer(Sender: TObject);
begin
If step>AboutDllForm.Image1.Height Then step:=AboutDllForm.Image1.Height
Else If step<-200 Then step:=AboutDllForm.Image1.Height
Else step:=step-1;
AboutDllForm.Paint;
end;
procedure TAboutDllForm.FormPaint(Sender: TObject);
var Bitmap:TBitMap;
begin
Bitmap:=TBitmap.Create;
Bitmap.LoadFromFile('about.bmp');
AboutDllForm.Image1.Canvas.Brush.Color:=clBlack;
AboutDllForm.Image1.Canvas.Rectangle(AboutDllForm.Image1.ClientRect);
AboutDllForm.Image1.Canvas.Draw(10,step,BitMap);
end;
end.
---------DLL的调用单元如下:
unit testdlg;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
Function AboutDllFormCreate:integer; stdcall; external 'about.dll';
procedure TForm1.Button1Click(Sender: TObject);
begin
AboutDllFormCreate;
end;
end.
程序的功能是在DLL中显示一个FORM,FORM中的IMAGE控件从下到上的动态显示一个图片
,实际运行中ABOUTUNIT中的SHOEMESSAGE可以正常显示,但是FORM不行,系统提示系统提示
access violation at adress in module 'about.dll',read of adress FFFFFFF
请问为什么,如何处理?????
library about;
uses
SysUtils,
Classes,
aboutunit in 'aboutunit.pas' {AboutDllForm};
{$R *.RES}
exports AboutDllFormCreate;
begin
end.
--------ABOUTUNIT单元如下:
unit aboutunit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TAboutDllForm = class(TForm)
Bevel1: TBevel;
Image1: TImage;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormPaint(Sender: TObject);
private
{ Private declarations }
step:integer;
public
{ Public declarations }
end;
var
AboutDllForm: TAboutDllForm;
function AboutDllFormCreate:integer; stdcall;
implementation
{$R *.DFM}
function AboutDllFormCreate:integer; stdcall;
begin
showmessage('hello');
AboutDllForm:=TAboutDllForm.Create(Application);
AboutDllForm.ShowModal;
end;
procedure TAboutDllForm.Timer1Timer(Sender: TObject);
begin
If step>AboutDllForm.Image1.Height Then step:=AboutDllForm.Image1.Height
Else If step<-200 Then step:=AboutDllForm.Image1.Height
Else step:=step-1;
AboutDllForm.Paint;
end;
procedure TAboutDllForm.FormPaint(Sender: TObject);
var Bitmap:TBitMap;
begin
Bitmap:=TBitmap.Create;
Bitmap.LoadFromFile('about.bmp');
AboutDllForm.Image1.Canvas.Brush.Color:=clBlack;
AboutDllForm.Image1.Canvas.Rectangle(AboutDllForm.Image1.ClientRect);
AboutDllForm.Image1.Canvas.Draw(10,step,BitMap);
end;
end.
---------DLL的调用单元如下:
unit testdlg;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
Function AboutDllFormCreate:integer; stdcall; external 'about.dll';
procedure TForm1.Button1Click(Sender: TObject);
begin
AboutDllFormCreate;
end;
end.
程序的功能是在DLL中显示一个FORM,FORM中的IMAGE控件从下到上的动态显示一个图片
,实际运行中ABOUTUNIT中的SHOEMESSAGE可以正常显示,但是FORM不行,系统提示系统提示
access violation at adress in module 'about.dll',read of adress FFFFFFF
请问为什么,如何处理?????