Page 1 of 1

How to pass a byte array from VB to C++ DLL

Posted: Thu Nov 24, 2011 10:04 pm
by Saman
Define the C++ DLL function as below.

Code: Select all

int __stdcall MyFunc(char *buf, long length);
Now declare the function in VB6 as below.

Code: Select all

Declare Function MyFunc(ByVal buf as Long, ByVal len As Long) As Long
Here is how you need to call it.

Code: Select all

Dim buf(1023) as Byte ' 1024 element array
MyFunc VarPtr(buf(0)), 1024