首先必须了解此函数在c中的原型,包括参数类型和传递方式。
c dll 原型 vb声明 vb调用
int a byval a as long call func(…,a,…)
long a byref a as long call func(…,byval a,…)
int *pa byref pa as long call func(…,pa,…)
long *pa byval pa as long call func(…,varptr(pa),…) *(1)
char *pstr byval pstr as string call func(…,pstr,…) *(2)
wchar *pstr byref pstr as string call func(…,byval pstr,…)
struct tagx *p byref p as tagx call func(…,ptag,…) *(3)
handle h byval h as long call func(…,h,…) *(4)
注意
1)不推荐使用此方式
2)如果dll要求一个字符串缓冲区,一定要在调用前初始化字串,即dim t as string * 50
3)用户定义子类型必须用byref方式传递,
4)任何内核对象的句柄(process, thread, module, file, filemapping, semaphore等)和大多数gdi对象的句柄都能用此方式传递。