vb代码如下:请用DEPHI 实现
Option Explicit
Private Declare Function VCGetDoc Lib "vcwfs.dll" (ByVal intNumber As Integer, ByVal strData As String) As Long
Private Sub Command1_Click()
Dim strTextAll As String * 50000strTextAll = " "
VCGetDoc 10, strTextAll
End Sub
注意:在vb中strTextAll 必须申明为50000,或者更大,因为strTextAll返回一个50000左右的字符串.若只定义dim strTextAll as String 将不能返回字符串,只能返回空字符串.

解决方案 »

  1.   

    function VCGetDoc(var intNum:Integer;var strData):LongInt;stdcall;
    external 'vcwfs.dll' name 'VCGetDoc';procedure Cmmand1_click;
    var
      strTextAll:string;
    begin
      strText:='';
      SetLength(strTextAll,50000);
      VcGetDoc(10,pchar(strTextAll));
    end;
      

  2.   

    VcGetDoc(10,pchar(strTextAll));
    这句编译错误:constant object cannot passed as var parameter.
      

  3.   

    function VCGetDoc(var intNum:Integer;var strData: String):LongInt;stdcall;
    external 'vcwfs.dll' name 'VCGetDoc';procedure Cmmand1_click;
    var
      strTextAll:string;
      intNum: Integer;
    begin
      strTextAll:='';
      SetLength(strTextAll,50000);
      intNum := 10;
      VcGetDoc(intNum,strTextAll);
    end;
      

  4.   

    function VCGetDoc(var intNum:Integer;var strData):LongInt;stdcall;
    external 'vcwfs.dll' name 'VCGetDoc';
    procedure Cmmand1_click;
    var
      strTextAll:string;
      I : integer; 
    begin
      strText:='';
      I := 10;
      SetLength(strTextAll,50000);
      VcGetDoc(I,pchar(strTextAll));
    end;
      

  5.   

    var
      strTextAll:WideString;
      I : integer; 
    begin
      VcGetDoc(10,pchar(strTextAll));
    end;
      

  6.   

    秋风舞的解答编译没有错误,但不能提出字符串,dephi中给dll中的函数传递字符串变量不能直接用string。应该用pchar.
    一滴蜜糖的解答同样和liufuyahong一样的编译错误
      

  7.   

    constant object cannot passed as var parameter不是指vcgetdoc(10,pchar(strTextALL))中参数10的错误,是参数strTextAll的错误好像是说strTextALL作为常量对象不能作为var参数传递。
      

  8.   

    问题好想很简单,上边这些楼主好好查看,肯定能解决问题!
    function VCGetDoc(intNum:Integer;strData):LongInt;stdcall;
    external 'vcwfs.dll' ;
    procedure Cmmand1_click;
    var
      strTextAll:string;
      K:integer;
    begin
      strText:='';
      k:=10;
      SetLength(strTextAll,50000);
      VcGetDoc(k,pchar(strTextAll));
    end;
      

  9.   

    的确存在delphi中string和vc中字符串问题不兼容问题,应该用pcharfunction VCGetDoc(intNum:Integer;strData:pchar):LongInt;stdcall;
    external 'vcwfs.dll' ;
    procedure Cmmand1_click;
    var
      strTextAll:pchar;
      K:integer;
    begin
      strText:='';
      k:=10;
      SetLength(strTextAll,50000);
      VcGetDoc(k,strTextAll);
    end;
      

  10.   

    天涯网客的代码在
    SetLength(strTextAll,50000);处出现编译错误:
    constant object cannot passed as var parameter
      

  11.   

    要和动态链接库传替string型的参数,一个方法用pchar一个方法是把sharememo作为引用单元放在uses的第一位,但我第二种方法没试过
      

  12.   

    function VCGetDoc(intNum:Integer;strData:pchar):LongInt;stdcall;
    external 'vcwfs.dll' ;
    procedure Cmmand1_click;
    var
      strTextAll:pchar;
      a:string;
      K:integer;
    begin
      strText:='';
      k:=10;
      SetLength(a,50000);
      strTextAll:=pchar(a);
      VcGetDoc(k,strTextAll);
    end;
      

  13.   

    终于解决了,是以于伟刚的代码为基础,搞成的
    我研究了一个星期。但小于代码还是有个小错误,a:string还是提不出来,改成a:widestring.才能提出字符串。可能与提出的字符串中有中文有关系。散分!