how can i create a two dimension safearray?

how can i create a two dimension safearray?

I want to create a two dimension safearray. But the third parameter of the  function SafeArrayCreate(vt, cDims, ab) defined in the oleaut32.f90 is a variable of TYPE(SA_BOUNDS). here is the define:

    INTEGER(INT_PTR_KIND()) FUNCTION SafeArrayCreate(vt, cDims, ab)
!DEC$ ATTRIBUTES DEFAULT, STDCALL, ALIAS : '_SafeArrayCreate@12' :: SafeArrayCreate 
!DEC$ ATTRIBUTES DEFAULT, STDCALL, ALIAS : 'SafeArrayCreate' :: SafeArrayCreate 
          use ifwinty
          INTEGER*4,     INTENT(IN)           :: vt
          !DEC$ ATTRIBUTES VALUE              :: vt
          INTEGER*4,     INTENT(IN)           :: cDims
          !DEC$ ATTRIBUTES VALUE              :: cDims
          TYPE(SA_BOUNDS), INTENT(IN)         :: ab
          !DEC$ ATTRIBUTES REFERENCE          :: ab
    END FUNCTION SafeArrayCreate

and here is the define of the SA_BOUNDS int the ifwinty.f90

          TYPE SA_BOUNDS
                INTEGER*4       extent
                INTEGER*4   lbound

in the SafeArrayCreate, ab is a variable of TYPE(SA_BOUNDS), not a pointer. however, in the msdn, the third parameter of SafeArrayCreate is a pointer, so i  can define a array of SAFEARRRAYBOUND , and pass the address to the third parameter to define a multidimension safearray.

SAFEARRAY * SafeArrayCreate(   VARTYPE vt,   unsigned int cDims, 

Can anybody help me how to define a multidimension safearray?


4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Declare the interface with

TYPE(SA_BOUNDS), INTENT(IN)         :: ab(dDims)

Jim Dempsey

So, you mean the interface in the oleaut32.f90 is wrong? Another question, Do you have some reference for me to write fortran COM program?

the book is scarce, Thank you!

I had a type-o, i had dDims, not cDims

If that interface were used to call a Fortran subroutine (your are not)
if cDims were .gt. 1

The yes, it would have been in error.

You are calling a C routine Both declarations would work

The original interface would work for that (assuming SEQUENCE use and your array elements are adjacent in memory)

Jim Dempsey

Leave a Comment

Please sign in to add a comment. Not a member? Join today