首先必须了解此函数在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对象的句柄都能用此方式传递。
没有相关教程
|