写这个小程序的时候没有想过用DLL(最后还是用了动态调用DLL的窗体),程序有十个个窗体.
问题:运行程序-仓库管理下的"收料"(调用DLL窗体,反复开启关闭没问题).关闭后运行基体资料下的"常用人员"(是这种普通调用窗体的方式:form1.windowstate:=wsminimized;
form10.SHOW;还有很多都是用的这种方式),运行正常.现在再反过来运行仓库管理下的"收料"(动态调用DLL窗体)时就报错"project vertex_erp.exe raised exception class eaccessviolation with message'access violation at address 000000048.read of address 000000048'.process stopped.use step or run to continue"所以我想问题是不是出在调用这里.DLL调用代码:
unit Unit6;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;type
TFrame6 = class(TFrame)
Label2: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
BitBtn5: TBitBtn;
BitBtn6: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure FrameExit(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
formref:longint;
function myshowform1(ahandle:thandle):longint;stdcall;
procedure mycloseform1(aformref:longint);stdcall;
implementation
function myshowform1;external 'dll_1.dll';
procedure mycloseform1;external 'dll_1.dll';{$R *.dfm}procedure TFrame6.BitBtn1Click(Sender: TObject);
begin
IF formref<>0 then
begin
mycloseform1(formref);
formref:=myshowform1(application.Handle);
end
else
begin
formref:=myshowform1(application.Handle);
end;
end;procedure TFrame6.FrameExit(Sender: TObject);
begin
mycloseform1(formref);
end;end.普通窗体的调用代码:
uses Unit10, Unit1, Unit11, Unit12, Unit13, Unit14, Unit15, Unit16, Unit17,
Unit18, Unit19, Unit20, Unit22, Unit23, Unit24;{$R *.dfm}procedure TFrame9.BitBtn1Click(Sender: TObject);
var
form10:tform10;
begin
form10:=tform10.Create(nil);
form10.ShowModal;
end;
问题:运行程序-仓库管理下的"收料"(调用DLL窗体,反复开启关闭没问题).关闭后运行基体资料下的"常用人员"(是这种普通调用窗体的方式:form1.windowstate:=wsminimized;
form10.SHOW;还有很多都是用的这种方式),运行正常.现在再反过来运行仓库管理下的"收料"(动态调用DLL窗体)时就报错"project vertex_erp.exe raised exception class eaccessviolation with message'access violation at address 000000048.read of address 000000048'.process stopped.use step or run to continue"所以我想问题是不是出在调用这里.DLL调用代码:
unit Unit6;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;type
TFrame6 = class(TFrame)
Label2: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
BitBtn5: TBitBtn;
BitBtn6: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure FrameExit(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
formref:longint;
function myshowform1(ahandle:thandle):longint;stdcall;
procedure mycloseform1(aformref:longint);stdcall;
implementation
function myshowform1;external 'dll_1.dll';
procedure mycloseform1;external 'dll_1.dll';{$R *.dfm}procedure TFrame6.BitBtn1Click(Sender: TObject);
begin
IF formref<>0 then
begin
mycloseform1(formref);
formref:=myshowform1(application.Handle);
end
else
begin
formref:=myshowform1(application.Handle);
end;
end;procedure TFrame6.FrameExit(Sender: TObject);
begin
mycloseform1(formref);
end;end.普通窗体的调用代码:
uses Unit10, Unit1, Unit11, Unit12, Unit13, Unit14, Unit15, Unit16, Unit17,
Unit18, Unit19, Unit20, Unit22, Unit23, Unit24;{$R *.dfm}procedure TFrame9.BitBtn1Click(Sender: TObject);
var
form10:tform10;
begin
form10:=tform10.Create(nil);
form10.ShowModal;
end;
解决方案 »
- 如图所示,如何格式化日期
- 把窗体程序做成系统服务。
- Delphi如何實現遠程控制SQL Server?(例如:遠程停止、啟動SQL Server)
- query为什么会报硬盘空间不足?
- 做了个小游戏,是关于24点的益智游戏,大家评评看!up有分!
- ★★★用Spy++获得的窗体句柄是16进制的(如:0006011C)。如何用一个edit控件和一个button控件和showwindow函数来显示这个窗体(要求:
- 关于插入记录的问题!
- 谁能讲一下POS(),COPY()函数的具体用法
- 麻烦各位帮看一下一小段程序(关于图片显示的),在线等待!!
- 急急急!请教如何使Tchart图表控件的X坐标为当前的时间并且是动态的(用在实时曲线中)?
- 自己做个消息框
- 无法实现选中文本
begin
IF formref <>0 then
begin
mycloseform1(formref);
formref:=myshowform1(application.Handle); //报错时就停在这里了.
procedure TForm1.Button1Click(Sender: TObject);
var
Handles :THandle;
ShowDLLFrom :TShowDLLFrom;
begin
try
Handles :=LoadLibrary('XXX.dll');
if Handles <>0 then
@ShowDLLFrom :=GetProcAddress(Handles ,'ShowDLLFrom');
if @ShowDLLFrom <>Nil then
ShowDLLFrom(Handle);
finally
FreeLibrary(Handles);
end;
end;//Dll中的ShowDLLFrom
function ShowDLLFrom(AHandle: THandle):Boolean;
var
AboutForm : TForm1 ;
begin
Application.Handle :=AHandle;
AboutForm := TForm1.Create(Application);
AboutForm.ShowModal;
AboutForm.Free;
end;