Jump to content

simply_red

Member
  • Posts

    3
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    Canada

Everything posted by simply_red

  1. 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 VB and C++ fill it. now i need VC++ to get an array of array of different sizes, and VB can'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 Variant Call Remplir_table(tab1)
  2. i am stupid it's not a pb with safearray the order was different Private Type GElement data() As Double S As Double S3 As Double End Type Private Type GElement S As Double S3 As Double data() As Double End Type
  3. Hi, i'm sorry for my english.... i have a program in vb 6 that use one function from c++ dll, it give it SafeArrays as parameteres.... all work good. the pb come when i use an activex control with the same code as the program in vb, and this control is used in excel..... the function in c++ have several safearrays as parameters, one of them i can't get it (the c++ can't 'catch' the data) all the other are just arrays of double or of struct, but the pb one is an array of struct witch contain an array Private Type GElement data() As Double S As Double S3 As Double End Type Private arGroupes() As GElement .... RetVal = myCppFunction(arGroupes(),...) ..... double __declspec(dllexport) CALLBACK myCppFunction(LPSAFEARRAY FAR *saData,....) ... GElement HUGEP * arGroupes; ... { .... SafeArrayAccessData(*saData, (void HUGEP**)&arGroupes); //arGroupe will not contain what it have to .... }
×
×
  • Create New...