CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 32

Threaded View

  1. #1
    Join Date
    Mar 2014
    Posts
    17

    Post accessing long pointer safearray structure in 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 ::
    Code:
    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::

    Code:
    public para() as configtable
    calling the dll function in vc++ ::

    Code:
    databaseinitialization(para,apppath)
    the structure in dll::
    Code:
    typedef struct
    {
    int pid;
    int configid;
    int wordno;
    LPVOID unit;
    float maxval;
    }PARAMETERS;
    function where i got the error ::
    Code:
    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:


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

    Code:
    paraTABLE=(PARAMETERS*) malloc (sizeof(PARAMETERS) * ptrPARAMDATA->rgsabound->cElements);
    but den its showing :
    Code:
    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 by sumlal; March 24th, 2014 at 05:49 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured