在bcb中把自定义结构传入DELPHI的dll中处理。  如
struct  AQuerySInfo  
{String  SetType;  
TList  *LabelList;  };  
发现无法正常传入结构中的数据,AQuerySInfo 这种自定义结构做参数,能在delphi的dll中调用吗?

解决方案 »

  1.   


    D可以用结构做参数。
    你要在D的公共单元里定义这样的结构。结构中最好不要使用string。
    使用string[255]。
    推荐使用pchar.传递的时候传递结构Addr.
    type
    pAQuerySInfo=^AQuerySInfo ;//这就是这个结构的指针。
    AQuerySInfo=record
    SetType:string;   
    LabelList:Tlist;
    end;
      

  2.   

    谢谢老大,我跟踪调试pAQuerySInfo的值现在能正常传入,但是返回值ADataSetInfo变成了乱码?
    pDataSetContentInfo结构里的
    pDataSetContentInfo.settype:='1' ;
    pDataSetContentInfo.Content:='ddd' ;DataSetInfo.ContentList.Add(@pDataSetContentInfo);
    返回值为DataSetInfo,返回后数值都变成了乱码?
    郁闷啊。
      

  3.   

    对BCB不熟但是如果是使用string的话, 应该是即使是delphi调用delphi的dll都会有问题, 需要在宿主程序和dll程序中都引用sharemem单元才可以, 这个单元引用了一个borlndmm.dll作为公共的内存管理模块, 才可以正确处理string作为函数参数在dell中使用楼主取查查BCB中是怎样引用这个sharemem模块的
      

  4.   

    //   If your DLL exports any functions that pass String objects (or structs/
    //   classes containing nested Strings) as parameter or function results,
    //   you will need to add the library MEMMGR.LIB to both the DLL project and
    //   any other projects that use the DLL. 
    谢谢,我的问题已经解决。
    1、用pchar代替了字符串
    2、把函数改为了过程,原返回值放在了参数里。