通过回调函数将数组形式的C ++ DLL传递给VB6 [英] passing array form C++ DLL to VB6 through call back function

查看:158
本文介绍了通过回调函数将数组形式的C ++ DLL传递给VB6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要将uint8数组从C ++ DLL传递到VB6应用程序,但是如果尝试使用数组'pabyData',我将始终收到以下错误消息:下标超出范围"在我的VB6过程中.

C过程是:

typedef void(__stdcall * FUNCPTR2SendData)(const uint8_t * pabyData,uint16_t wDataLength);

void SendData(const uint8_t * pabyData,uint16_t wDataLength)
{
     FUNCPTR2SendData vbFunc;
    vbFunc =(FUNCPTR2SendData)ptCBFPointers-> p2NewDirectDataSMSEvnt;
   //ptCBFPointers是回调指针,在其中保存了VB6函数的回调地址
    vbFunc(pabyData,wDataLength);
}

VB6过程是:
Public Sub SendData(ByRef pabyData()以字节为单位,ByVal wDataLength以整数为单位)
. ..

我应该怎么做?

谢谢.

Hi,

I need to pass an uint8 array from C++ DLL to VB6 application but I receive always following error: "subscript out of range" if I try to work with the array 'pabyData' in my VB6 procedure.

The C procedure is:

typedef void (__stdcall *FUNCPTR2SendData) (const uint8_t* pabyData, uint16_t wDataLength);

void SendData(const uint8_t* pabyData, uint16_t wDataLength)
{
    FUNCPTR2SendData vbFunc;
    vbFunc = (FUNCPTR2SendData) ptCBFPointers->p2NewDirectDataSMSEvnt;
   // ptCBFPointers are call back pointers, where is saved the call back address of VB6 functions
    vbFunc(pabyData, wDataLength);
}

The VB6 procedure is:
Public Sub SendData(ByRef pabyData() As Byte, ByVal wDataLength As Integer)
...

How should I do it?

Thanks.

推荐答案

我看到这是一篇非常古老的文章,但是以防万一有人遇到类似问题,我会尽力至少提供一些建议.无需过多研究您的代码,如果我没记错的话,VB数组的起始下标为1,而 C ++基本下标为0.在两种语言之间传递数组时可能会出现问题...

I see that this is a very old post, but just in case someone comes along with a similar issue, I'll try my best to at least give some advice. Without looking too far into your code, If I remember correctly, VB arrays have a starting subscript of 1 whereas C++ base subscript is 0. This may be an issue when passing arrays between the two languages...


这篇关于通过回调函数将数组形式的C ++ DLL传递给VB6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆