我想动态调用DLL,声明了这两个类型,但编译时总提示函数需要返回值。为什么啊?
我看别的例子都是这样用的啊
Type TStrEncrypt = function StrEncrypt(const sInput: string): string; stdcall;
Type TStrDecrypt = function StrDecrypt(const sInput: string): string; stdcall;

解决方案 »

  1.   


    Type TStrEncrypt = function (const sInput: string): string; stdcall; 
    Type TStrDecrypt = function (const sInput: string): string; stdcall;
      

  2.   

    DLL文件里的函数在声明时,传入和返回的参数可以是string吗?
    我刚才试了下,如果返回值是string 出错,如果改成返回值是Pchar,就不会错了Type TStrEncrypt = function (const sInput: string): PChar; stdcall; 
    传入参数是string表面看是不出错的。但这样写好吗?
    学习中
      

  3.   

    可以是,也有办法解决,但不推荐用string,主要原因是dll程序不应该使用某种语言特有的数据类型
      

  4.   

    要用string的要引用sharemem单元
      

  5.   


    String  是DELPHI特有的东西,内存管理的问题 建议用PCHAR
      

  6.   


    如果一定要用的话就在  uses  的时候首先带上 shareMem 并把  borlandmm.dll 一起发布来管理内存
      

  7.   

    还有shareMem 一定要放在单元引用第一位!