VB调用C函数时数组传参的问题
该文章迁移自作者的旧博客站点。
源地址:http://fenying.blog.163.com/blog/static/10205599320135231255816/。
源地址:http://fenying.blog.163.com/blog/static/10205599320135231255816/。
其实这是对《VC++写DLL给VB使用》一文的补充,网易不让编辑太古老的文章……
今天有人找我问关于VB调用DLL里函数的问题,该函数如下:
int __stdcall func1(char *pStr, mystruct mst[]);
在VB里声明如下:
Private Declare Function func1 Lib "dll1.dll" (ByRef aStr As String, ByRef pMST As mystruct) As Long
调用方式为:
Dim MSTs(100) As mystruct
MsgBox func1(str1, MSTs(0))
这里解释下,ByRef MSTs(0)
其实就是取数组首地址,因此就是数组的引用传递了。
comments powered by Disqus