用PCHAR参数试试看,不要用STRING

解决方案 »

  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. }解决方法1:
      project2(工程文件,不是单元文件)的uses中第一项(新增加)为ShareMem
      project1的uses中第一项(新增加)为ShareMem解决方法2:使用,不用string传递参数
    function getMyInfo(myInt1,myInt2:Integer):pchar;StdCall;
    begin
      Result:=pchar(IntToStr(myInt1+myInt2));
    end;
    ---------------------------------------------------------------------
    function getMyInfo(myInt1,myInt2:Integer):pchar;StdCall external 'project1.dll';
    procedure TForm1.BitBtn1Click(Sender: TObject);
    begin
      MessageDlg('Result is:'+string(getMyInfo(2,3)), mtInformation,[mbOk], 0);
    end;
      

  2.   

    其实我就是看到零分,我想很少人会来的,所以发挥一下,真要谢谢li_flying
    同学给我们机会。:)
      

  3.   

    用ShortString吧。
    如果用string可以uses那个me什么单元,然后实时包
      

  4.   

    大家真是高手阿,谢谢pdsinfo和Almzg_0等
      

  5.   

    广告插播http://www.csdn.net/Expert/topic/457/457590.shtm
    帮忙多谢
      

  6.   

    http://www.csdn.net/Expert/topic/457/457590.shtm