用delphi写的dll,其中封装了第三方的com对象,有string类型的参数,但在pb中调用出内存错误
delphi中的声明:
Function ReturnSMS(var sender:widestring; var receiver:widestring; var sms:widestring;
              cut:integer; notitle:integer):pchar;
pb中的声明:
Function string ReturnSMS(ref string sender, ref string receiver, ref string sms,  int cut,  int notitle) library "testdll.dll"

解决方案 »

  1.   

    制作dll不要用delphi特有的东西,我想你使用PWideChar比较好。
      

  2.   

    { 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. }
      

  3.   

    是com对象方法的参数问题
    RTXParams是com对象,对SENDER附值,
    paramstr是传递的参数(string,widestring都试过)
    RTXParams.Add('SENDER', paramstr);
    在pb中调用时出错,
      

  4.   

    ok了
    用pchar传参数,在dll将pchar转为string