fucntion ReadVersion(VersionInfo:PChaar); stdcall;external 'TestDll.dll';var
  VersionInfo:string;
begin
  SetLength(VersionInfo,YourMaxLen);//ex:YourMaxLen = 255;
  ReadVersion(PChar(VersionInfo));
  SetLength(VersionInfo,StrLen(VersionInfo));
  //应该可以在这里用了end;

解决方案 »

  1.   

    var VersionInfo: array[0..255] of char;begin
        fillchar(VersionInfo,0,256);
        ReadVersion(@VersionInfo[0]);
        ShowMessage(VersionInfo);
    end;
      

  2.   

    to GreensPan(GreensPan--> ReadVersion(PChar(VersionInfo));
    error:
    incompatible types:'string' and 'Pchar'
      

  3.   

    我试了一下,这样行。(在shinesi(阿shine) 基础上)
    var
     version:array[0..255] of char;
    begin
    if ReadVersionString(version) then
         ShowMessage(version);
    end;to shinesi(阿shine) 
     fillchar(VersionInfo,0,256);-->error:
     Not enough actual parameedrs谢谢!
      

  4.   

    应写为
    fillchar(VersionInfo,256,0);
      

  5.   

    没有什么好的办法,
    听课,Pchar应该就是指针,但是。。
      

  6.   

    不好意思使这句出错了
    SetLength(VersionInfo,StrLen(VersionInfo));
    是:
    SetLength(VersionInfo,StrLen(PChar(VersionInfo)));
    参考一下Delphi5开发人员指南27-28页理解了就行了
      

  7.   

    还有一个这样的Function:
    ****API SetDispString(const char* strData);
      strData:不超过16个字符
    ---------------------------------
     function SetDispString(str:pchar):bool;stdcall;external 'Testdll.dll' name 'SetDispString';
    //设置设备的显示字符
    同理怎么样要将Edit1.text的字符传送到设置屏幕中?
      

  8.   

    fucntion ReadVersion(VersionInfo:PChaar); stdcall;external 'TestDll.dll';var
      VersionInfo:PChar;
    begin
      VersionInfo := StrAlloc(100);
      ReadVersion(VersionInfo);
      ShowMessage(VersionInfo);
      StrDispose(VersionInfo);
    end;StrAlloc()函数是专门给PChar分配内存的。
      

  9.   

    function SetDispString(str:pchar):bool;stdcall;external 'Testdll.dll' name 'SetDispString';var
     str : PChar;
    begin
     str := StrAlloc(Length(Edit1.Caption) + 1);
     StrPCopy(str, Edit1.Caption);
     SetDispString(str);
     StrDispose(str);
    end;肯定可以。在Windows API中很多时候都需要用到PChar的。
      

  10.   

    还有一个这样的Function:
    ****API SetDispString(const char* strData);
      strData:不超过16个字符
    ---------------------------------
     function SetDispString(str:pchar):bool;stdcall;external 'Testdll.dll' name 'SetDispString';
    //设置设备的显示字符
    同理怎么样要将Edit1.text的字符传送到设置屏幕中?
      

  11.   

    to gfzhx(小小) :
     你的方法是可行,但执行完后会提示:
     
    该程序执行了非法操作,即将关闭。
    如果仍有问题请与程序供应商联系。???