小编use*_*639的帖子

Delphi:在dll中调用过程后访问冲突

我在dll中创建了一个打开表单然后打印报表的过程.这个过程完全适用于exe.我已经包含了包含此过程的单元并在dll中形成并导出过程如下:

{$R *.res}


Procedure PrintTopSellers; stdcall;
begin
  Form1 := TForm1.create(nil);
  GetMonth := TGetMonth.create(nil);
  Form1.PrintTopSellers;
end;


exports PrintTopSellers;

begin
end.
Run Code Online (Sandbox Code Playgroud)

现在我从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;
Run Code Online (Sandbox Code Playgroud)

对程序的调用完美无缺.但是,在我关闭调用exe之后,我收到了访问冲突 - "地址00BAC89C处的访问冲突.读取地址00BAC89C".

感谢任何帮助.我正在使用Delphi 7.谢谢

delphi delphi-7

5
推荐指数
1
解决办法
5393
查看次数

标签 统计

delphi ×1

delphi-7 ×1