simply_red Posted July 31, 2007 Posted July 31, 2007 I'm using VC6.i have a DLL written in VC6 and used by VB6( and VBA Excel),i use SafeArray as parameter, the array is created(declared), in VBand C++ fill it.now i need VC++ to get an array of array of different sizes, and VBcan't know the size of these arrays, so the arrays will be 'created'in VC.here the code that i use(and it crashes):void __declspec(dllexport) CALLBACK Remplir_table(LPSAFEARRAY FAR*tab1){ VARIANT HUGEP * CONTENU; SAFEARRAYBOUND sabound[1]; // 1-D array SAFEARRAY FAR* psa = NULL; // SAFEARRAY structure pointer VARIANT TEMPORARY; VariantInit(&TEMPORARY); SafeArrayAccessData(*tab1, (void HUGEP**)&CONTENU); sabound[0].lLbound = 0; sabound[0].cElements = 2; for (int i = 0; i<2; i++) { psa = SafeArrayCreate( VT_R4, 1, sabound ); float HUGEP* ResData; SafeArrayAccessData(psa, (void HUGEP**)&ResData); ResData[0] = 1.5; //just for test ResData[1] = 0.75;//just for test V_VT(&TEMPORARY ) = VT_ARRAY | VT_R4; V_ARRAY(&TEMPORARY) = psa; SafeArrayUnaccessData(psa); VariantCopy(&CONTENU,&TEMPORARY); } SafeArrayUnaccessData(*tab1);}the vb side:Dim tab1(1) As VariantCall Remplir_table(tab1)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now