07年最后一次紧急呼救:VB如何调用这个复杂的C++的DLL,先谢谢大家啦。

zhqi 2007-12-29 11:01:27
07年最后一次紧急呼救:VB如何调用这个复杂的C++的DLL,先谢谢大家啦。

DLL的中函数的参数是结构体,在C++中结构体定义如下:

struct ZT_USBBOARD{
long lIndex;
HANDLE hHandle;
short nCh;
long lData;
long* plData;
long lCode;
};

DLL中的函数定义如下:

long APIENTRY OpenUSB7kC(ZT_USBBOARD* bs)

问题:
1、如何引用参数为结构体的DLL?
2、结构体中HANDLE类型,在VB中如何定义?
3、指针类型的变量(如long*),在VB中如何定义?

呵呵,小弟第一次学着用VB调用C++ DLL,就遇到那么复杂的情况。

最好能给我一个实例代码:

Public Type ctrlStruct
usbIndex As Long
....
'这里如何写????
End Type

Private Declare Function OpenUSB7kC Lib ".\Usb7kC.dll" (ByRef pResult As ctrlStruct) As long
'这样写也不知道对不对??


请大家帮帮我,十分感谢!!!
...全文
52 点赞 收藏 5
写回复
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
caofusheng 2007-12-29
上边我写错了



Public Declare Function OpenUSB7kCLib "Usb7kC.dll" Alias "OpenUSB7kCLibA" (ByRef pResult As ZT_USBBOARD) As Long
Public Type ZT_USBBOARD
lIndex As Long
hHandle as long
nCh as integer
lData as long
plData as long
lCode as long
End Type
回复
caofusheng 2007-12-29

Public Declare Function OpenUSB7kCLib "Usb7kC.dll" Alias "OpenUSB7kCA" (ByVal lIndexAs Long, ByVal hHandle As long , ByVal nCh As integer , ByVal lData As Long, plData As Long,lCode As Long) As Long

Public Type ZT_USBBOARD
lIndex As Long
hHandle as long
nCh as integer
lData as long
plData as long
lCode as long
End Type
回复
Tiger_Zhao 2007-12-29
C中的long类型应该是Int64吧,VB中没有直接的数据类型可对应,不过可以用Currency代替。
因为Currency其实是定点小数,所以VB中Currency类型的0.0001对应C中long类型的1,按照这个比率处理就可以了。
回复
chenhui530 2007-12-29
Public Type ctrlStruct
usbIndex As Long
hHandle as long
nCh as integer
lData as long
plData as long
lCode as long
End Type
回复
junki 2007-12-29
楼上方法可以,vb参数默认是按传址进行的
回复
发动态
发帖子
VB基础类
创建于2007-09-28

7451

社区成员

VB 基础类
申请成为版主
社区公告
暂无公告