//dll的问题,delphi7下编译
function Test1(sTmp1, sTmp2: string): string;stdcall;
begin
  Result := sTmp1 + sTmp2;
end;exports
  Test1;//调用
var
  sTmp1: string;
  sTmp2: string;
  sTmp3: string;
begin
  sTmp1 := '66';
  sTmp2 := '77';
  sTmp3 := Test1(sTmp1,sTmp2);
  ShowMessage(sTmp3);
end;
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EInvalidPointer with message 'Invalid pointer operation'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help   
---------------------------
报错

解决方案 »

  1.   

    静态引用function Test1(sTmp1, sTmp2: string): string; stdcall;
    external 'dll\Main.dll';
      

  2.   

    1.调用方法错
    2.最好在dll中函数的返回值不要用string类型
      

  3.   

    function Test1(sTmp1, sTmp2: string): string; stdcall;
    external 'dll\Main.dll';这样最好指明具体路径
    //
    use
       shareMem
      

  4.   

    用pchar试试
    楼主换成整型肯定没问题的
      

  5.   

    delphi2010下没问题
    楼上说引用错了,请明示
      

  6.   

    //我觉得4楼,说的基本差不多。主要就是以下几点
    1.function Test1(sTmp1, sTmp2: string): string; stdcall; external 'dll.dll'; 
    2.另外就是在dll要加ShareMem单元引用。
    3.在调用dll程序的project单元,要加sharemem单元引用。
    4.另外在调用程序中加上borlndmm.dll,这个文件。
    基本就没什么问题了。
    //delphi 7,xp系统,我们就是这么处理的。
      

  7.   

    要么是这种:function Test1(sTmp1, sTmp2: string): string; stdcall; external 'dll.dll'; 
    要么是这种:function Test1(sTmp1, sTmp2: string): string; stdcall; external 'D:\dll\Main.dll'; 
      

  8.   

    把 strring 类型改成 array of char  就没有问题了.