Howto Passing Arrays to a DLL Procedure

The parameter of the procedure in the DLL is an integer array, which showed in VB is "Dim Buffer(9) As Integer". However, when it was imported in VC, the parameter was changed into "SAFEARRAY * * Buffer".
SAFEARRAY is a structure.

BOOL ReadUO(long Index, SAFEARRAY * * Buffer, long Count)
BOOL result;
static BYTE parms[] = VTS_I4 VTS_UNKNOWN VTS_I4 ;
InvokeHelper(0x60030015, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms, Index, Buffer, Count);
return result;

My code is as follows:

int Buffer[9];
long UOIndex = 1;
long Count = 10;
COleSafeArray *pSA_Buffer = new COleSafeArray((LPCSAFEARRAY)Buffer, VT_R4);
this->m_pCore->ReadUO(UOIndex, (SAFEARRAY **)&pSA_Buffer, Count);

But I was failed when constructure the COleSafeArray object.
== blueeyesblue ==
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!