我的dll文件:
library Project2;
uses
  ShareMem,
  SysUtils,
  Forms,
  Windows,
  Messages,
  Classes;    Function read(b1:Longint;d1:Longint;a1:pchar):Longint; stdcall ;
    begin
        if (b1=1)and (d1=3) and (a1='123456789')then
           begin
            Result:=0;
            a1:='987654321'
           end
        else
            Result:=1;
    end ;{$R *.res}
end;
  exports
    read name 'Read';begin
end.调用程序的函数:
Function  Read b1:Longint;d1:Longint;a1:pchar):Longint;stdcall;external   'Project2.dll'; 
var
tt:pchar;
begin
    tt:='000000';
    Label1.Caption:=inttostr(dogread(6,80,tt));
    Label2.Caption:=tt;   // 想这里的值变为:'987654321'
end

解决方案 »

  1.   

    Label1.Caption:=inttostr(dogread(6,80,tt));
    Label2.Caption:=tt; // 想这里的值变为:'987654321'
    //这里是不能这样子做的,不能像这样子传值,   建议lz用CreateFileMapping
    或者给主窗体发送sendMessage
      

  2.   

    a1前加out就行了
    Function read(b1:Longint;d1:Longint;out a1:pchar):Longint; stdcall ;
      

  3.   

    调用那里也要加上outFunction Read b1:Longint;d1:Longint;out a1:pchar):Longint;stdcall;external 'Project2.dll';
      

  4.   


    试试返回一个record指针吧
      

  5.   

    record指针?再详细一点嘛。大哥。
      

  6.   

    个人感觉你的字符串赋值与比较不对
    应该用strpcopy,CompareMem
    参考:
    http://jian100305.host10.web-75.com/tech/questionlist.asp?q_ID=7