关于向API函数传递参数的问题~~~

michael_zy 2005-08-06 02:28:26
函数原型太长,现在先贴个测试版本~~~

'DLL中输出函数的原形
'-1:
'void WINAPI HelloWorld (char *prompt,char * title)
'{
' MessageBox (0, prompt, title, MB_ICONINFORMATION);
'}

'VB中的声明:

Private Declare Sub HelloWorld Lib "tasm.dll" (ByVal prompt As String, ByVal title As String)

'函数调用: 'Call HelloWorld("Hello world", "Hi") '这里是成功的~~~~~!!!!!

下面把函数改成数组,其参数应该怎么传递,,,,谢谢,,,,在线等!!!!

'-2:
' void WINAPI HelloWorld (int c,char **prompt)
'{
' int i;
' char buf[1024];
' memset(buf,0,1024);
' for (i=1;i<c;i++)
' strcat(buf, prompt);
' MessageBox (0, buf, prompt[0], MB_ICONINFORMATION);
'}

函数声明:Private Declare Sub HelloWorld Lib "tasm.dll" (ByVal iCount As Long, prompt() As String)

函数调用:(下面的调用代码是不可行的,请教如何传递,,,我已经试过很多种方法了)

Dim prompt(3) As String
prompt(0) = " hello"
prompt(1) = " yun"
prompt(2) = " Hi"
prompt(3) = " finish"
HelloWorld 3&, prompt

...全文
104 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
michael_zy 2005-08-07
  • 打赏
  • 举报
回复
非常感谢楼几位朋友的回答~~~
Dim prompt(3) As String
prompt(0) = " hello"
prompt(1) = " yun"
prompt(2) = " Hi"
prompt(3) = " finish"
HelloWorld 3&, prompt(0)
这样传递测试过了,不可行。。。

prompt() as string 默认为ByRef,所以加和不加是一样的~~~
londywolf 2005-08-06
  • 打赏
  • 举报
回复
Private Declare Sub HelloWorld Lib "tasm.dll" (ByVal iCount As Long, prompt() As String)
数组参数传递要地址
改成
Private Declare Sub HelloWorld Lib "tasm.dll" (ByVal iCount As Long, Byref prompt() As String)
试试
laihongbo524 2005-08-06
  • 打赏
  • 举报
回复
Dim prompt(3) As String
prompt(0) = " hello"
prompt(1) = " yun"
prompt(2) = " Hi"
prompt(3) = " finish"
HelloWorld 3&, prompt(0)
londywolf 2005-08-06
  • 打赏
  • 举报
回复
传递数组第一个元素的地址试试
michael_zy 2005-08-06
  • 打赏
  • 举报
回复
沉得好快,up up ,,进来的朋友也帮忙顶顶
michael_zy 2005-08-06
  • 打赏
  • 举报
回复
在顶顶自己~~~~~~~~~~~up up up
michael_zy 2005-08-06
  • 打赏
  • 举报
回复
自己帮自己顶顶,等待高人~~~

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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