【发布时间】:2012-09-12 17:03:21
【问题描述】:
我在 dll 中创建了一个过程,该过程打开一个表单,然后打印一个报告。 此过程可通过 exe 完美运行。 我已将包含此过程和表单的单元包装在一个 dll 中,并将该过程导出如下:
{$R *.res}
Procedure PrintTopSellers; stdcall;
begin
Form1 := TForm1.create(nil);
GetMonth := TGetMonth.create(nil);
Form1.PrintTopSellers;
end;
exports PrintTopSellers;
begin
end.
现在我从一个 exe 调用这个过程 PrintTopSellers,如下所示:
procedure TForm1.Button5Click(Sender: TObject);
type
TRead_iButton = function :integer;
var
DLL_Handle: THandle;
Read_iButton: TRead_iButton;
Begin
DLL_Handle := LoadLibrary('c:\Catalog.dll');
if DLL_Handle <> 0 then
begin
@Read_iButton:= GetProcAddress(DLL_Handle, 'PrintTopSellers');
Read_iButton;
end;
application.ProcessMessages;
FreeLibrary(DLL_Handle);
end;
对该过程的调用完美无缺。但是,在我关闭调用 exe 后,我得到一个访问冲突 - “地址 00BAC89C 的访问冲突。读取地址 00BAC89C。”
感谢任何帮助。我正在使用德尔福 7。 谢谢
【问题讨论】:
-
安装堆栈跟踪器,如 Jedi CodeLibrary(由 Delphi IDE 使用)、Eureka、madExcept 中的异常对话框等...使用调试信息运行。检查异常的堆栈跟踪以了解火车在轨道上的位置。
-
你已经解决了这个问题吗?我有一些问题。但仅限于XP。在Win7上运行良好。我只需要在dll中创建并释放表单,然后在exe关闭后出现该错误。我正在使用 DelphiXE。