用delphi2007写了个DLL,libray test;uses 
   sharemem,
  sysutils,
classes,
activex;
function getstr:string;
begin
  result:='helll';
end;
exports
  getstr;begin
end;这样也会有错误。有没有朋友做过。

解决方案 »

  1.   

    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.
    no use string;
      

  2.   

    这个我知道啊,但是delphi7以前的版本是可以的啊.
      

  3.   

    fastmm 与BorladMM的问题。这样很不方便,想使用widestring就不行了
      

  4.   

    怪,widestring 返回的DLL在bcb里可以调用。还没有错。delphi7调用完就内存错误消失了。
      

  5.   

    use Pchar replace String!