可以调用过程,可是调用完后就进入一个像汇编程序一样的调试界面,并提示:too many consecutive exceptions 'access violation at 0x000000:read of address 0x000000' .
不知道是什么原因?
//动态连接库
library Project1;{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }uses
  sharemem,Dialogs,
  SysUtils,
  Classes;{$R *.res}
procedure display;export;
begin
  showmessage('dll dialog');
end;
exports
  display;
begin
end.//程序调用
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  Tsh = procedure;
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;
  p:Tsh;
  MyHandle:THandle;
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
   MyHandle:=windows.LoadLibrary('.\project1.dll');
   if MyHandle<>0 then
   begin
      @p:=windows.GetProcAddress(MyHandle,'display');
      if  @p<>nil then
      begin
         Tsh(p);
         windows.FreeLibrary(MyHandle);
      end;
   end
   else ShowMessage('DLL do not exist.');  // Windows.FreeLibrary(MyHandle);
end;end.

解决方案 »

  1.   

    我不太懂 Delphi ,但你可以用 odb 调试一下,或者把文件发过来我帮你看看。
      

  2.   

    procedure display;export;stdcall;
    begin
      showmessage('dll dialog');
    end;type
      Tsh = procedure;stdcall;
      

  3.   

    delphi写的dll, delphi调用, 需要LoadLibrary这么复杂么?
    procedure display; external 'project1.dll';
      

  4.   

    Tsh = procedure();
    要不会不知道是你的dll接口还是对procedure 的从新定义.这个会产生歧义,最好是随便定义一个参数什么的比较好.
      

  5.   

    是由于你使用了Sharemem单元引起的。你在导出的dll函数中并没有使用string类型字符串也没有共享什么内存块,所以你没必要引入sharemem单元。