DLL内容:
library test_dll;{ 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
  dialogs,
  controls,
  messages,
  windows,
  sysutils,
  Classes;function test(x:string):string;stdcall;{$R *.res}function test(x:string):string;
begin
    showmessage(x);
end;
end.
出错信息:[Error] test_dll.dpr(31): BEGIN expected but END found
[Error] test_dll.dpr(36): Declaration expected but end of file found偶不知道什么意思了,我究竟错在哪里了??
另外,我的调用DLL的程序是:unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
  function test(x:string):string stdcall;external'test_dll.dll';var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
    test('call dll file');
end;end.

解决方案 »

  1.   

    http://www.ahetc.gov.cn/cit/200008/02.htm
      

  2.   

    library test_dll;{ 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
      dialogs,
      controls,
      messages,
      windows,
      sysutils,
      Classes;function test(x:string):string;stdcall;{$R *.res}function test(x:string):string;
    begin
        showmessage(x);
    end;Exports//////////////
     test;///////////
    end.
    Dll中方法要导出来要注意大小写的区分
      

  3.   

    我现在改为
    library test_dll;{ 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
      dialogs,
      controls,
      messages,
      windows,
      sysutils,
      Classes;function test(x:string):string;stdcall;{$R *.res}function test(x:string):string;
    begin
        showmessage(x);
    end;Exports 
     test;
    begin
    end.还是无法编译啊
      

  4.   

    library test_dll;{ 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
      ExceptionLog,
      dialogs,
      controls,
      messages,
      windows,
      sysutils,
      Classes;function test(x:string):string;
    begin
        showmessage(x);
    end;Exports test;
    begin
    e
      

  5.   

    library test_dll;uses
      dialogs;function test(x:string):string; stdcall;
    begin
        showmessage(x);
    end;exports
      test;begin
    end.
      

  6.   

    blazingfire(烈焰)(对.net极度憎恨中....) 你这个成了,可是,为什么啊,为什么我的那个就不行啊??
      

  7.   

    为什么用stdcall声明一下不可以,而在写函数的时候再加上就可以了呢??
      

  8.   

    stdcall只是约定参数的调用方式而已,
    要注意在Pas文件里,你能先声明一个函数再去定义它,但在.dpr文件中,你只能实现这个函数,不能声明,因为在dpr中不能用implementation子句了,所以stdcall要在函数实现时写。
    如果有声明时,只要在声明时写就OK了。
      

  9.   

    声明是在implementation前,实现是在implementation后。
    不要问我为什么dpr中不能用implementation子句,这个要问安德生或恰克 ^o^