accessing safearray structure in simple dll

hello friends,

i am debugging a dll file for an application and i am getting some problem in accessing the safearray structure in the dll file.
the application wes developed in vc++ 2005 now upgrading it to vc++2008.
For the front end there using vb script 2005.

so the problem is i am passing a structure type array (that is having data fatched from the ole database) to a dll as a LPSAFEARRAY parameter,when i executing the front end, the dll is accessing properly but when its going to allocate the memory its sending the error report (other memkry corrupted) from the backend. but when i compiling the backend dll its not giving any error.and when i trace the each and every line of the dll from the front end got to know that the problem is while its allocating the memory. i am giving a few details of the coding please someone help me to figure this out.

vb code ::

1
2
3
4
5
6
7
structure configtable
public pid as long
public configid as long
public wordno as long
public unit as string
public maxval as single
end structure 


declearation of array in vb::

public para() as configtable

calling the dll function in vc++ ::

databaseinitialization(para,apppath)

the structure in dll::

1
2
3
4
5
6
7
8
typedef struct
{
int pid;
int configid;
int wordno;
LPVOID unit;
float maxval;
}PARAMETERS;


function where i got the error ::

1
2
3
4
5
6
7
databaseinitialization(LPSAFEARRAY FAR *prtPARAMDATA, LPSTR path)
{

PARAMETERS *paraTABLE;

paraTABLE=(PARAMETERS*) malloc (sizeof(PARAMETERS) * (*ptrPARAMDATA)->rgsabound->cElements); //the error line
}



i have also tried by giving like but den its givig some while compiling the dll:



paraTABLE=(PARAMETERS*) malloc (sizeof(PARAMETERS) * (*ptrPARAMDATA).rgsabound[0].cElements);
or

paraTABLE=(PARAMETERS*) malloc (sizeof(PARAMETERS) * ptrPARAMDATA->rgsabound->cElements);

but den its showing :

error C2227:left of '->rgsabound' must point to class/struct/union/generic type.

error C2227:left of '->cElements' must point to class/struct/union/generic type.

full code is not given but this line in the databaseinitialization is not executing.waiting for reply...
Last edited on
Topic archived. No new replies allowed.