PDA

Click to See Complete Forum and Search --> : Passing a VB Byte Array into a C++ DLL


CactusCat
Oct 13th, 2002, 08:27 AM
Can someone give me an example of how I can pass an array of Bytes (from VB) into a C++ DLL?
I know I've got to pass the length of the array, as well as the first array element (I think?). But I would appreciate an example to work from.

CornedBee
Oct 13th, 2002, 11:23 AM
void __stdcall PassArrayTo(char *ar, long length);

Declare Sub PassArrayTo ... (ByVal ar as Long, ByVal len As Long)

'Call:
PassArrayTo VarPtr(array(1)), UBound(array)

CactusCat
Oct 13th, 2002, 11:39 AM
Does that require the VB Array to be of type 'long'?

CornedBee
Oct 13th, 2002, 11:43 AM
No. It's Long because Long has the same size as a pointer. The return value of VarPtr is Long.

CactusCat
Oct 13th, 2002, 11:51 AM
thanks... sorry you had to tell me twice!