救命,在线等待!解决了问题,经本人马上试验无误,十分中之类必然结帖。

zhangcyu 2003-10-16 04:08:09
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 * 50000

strTextAll = " "
VCGetDoc 10, strTextAll
End Sub
注意:在vb中strTextAll 必须申明为50000,或者更大,因为strTextAll返回一个50000左右的字符串.若只定义dim strTextAll as String 将不能返回字符串,只能返回空字符串.
...全文
30 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangcyu 2003-10-16
  • 打赏
  • 举报
回复
终于解决了,是以于伟刚的代码为基础,搞成的
我研究了一个星期。但小于代码还是有个小错误,a:string还是提不出来,改成a:widestring.才能提出字符串。可能与提出的字符串中有中文有关系。散分!
dickeybird888 2003-10-16
  • 打赏
  • 举报
回复
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;

zhangcyu 2003-10-16
  • 打赏
  • 举报
回复
我现在只需要第一中方法解决
谁能解决?????
herofy 2003-10-16
  • 打赏
  • 举报
回复
要和动态链接库传替string型的参数,一个方法用pchar一个方法是把sharememo作为引用单元放在uses的第一位,但我第二种方法没试过
zhangcyu 2003-10-16
  • 打赏
  • 举报
回复
天涯网客的代码在
SetLength(strTextAll,50000);处出现编译错误:
constant object cannot passed as var parameter
yaven365 2003-10-16
  • 打赏
  • 举报
回复
的确存在delphi中string和vc中字符串问题不兼容问题,应该用pchar

function 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;
yaven365 2003-10-16
  • 打赏
  • 举报
回复
问题好想很简单,上边这些楼主好好查看,肯定能解决问题!
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;
zhangcyu 2003-10-16
  • 打赏
  • 举报
回复
constant object cannot passed as var parameter不是指vcgetdoc(10,pchar(strTextALL))中参数10的错误,是参数strTextAll的错误好像是说strTextALL作为常量对象不能作为var参数传递。
zhangcyu 2003-10-16
  • 打赏
  • 举报
回复
秋风舞的解答编译没有错误,但不能提出字符串,dephi中给dll中的函数传递字符串变量不能直接用string。应该用pchar.
一滴蜜糖的解答同样和liufuyahong一样的编译错误
libra163 2003-10-16
  • 打赏
  • 举报
回复
var
strTextAll:WideString;
I : integer;
begin
VcGetDoc(10,pchar(strTextAll));
end;
free007 2003-10-16
  • 打赏
  • 举报
回复
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;
snowfog 2003-10-16
  • 打赏
  • 举报
回复
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;
zhangcyu 2003-10-16
  • 打赏
  • 举报
回复
VcGetDoc(10,pchar(strTextAll));
这句编译错误:constant object cannot passed as var parameter.
liufuyahong 2003-10-16
  • 打赏
  • 举报
回复
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;

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧