# 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\$IF DEFINED(_X86_)
!DEC\$ ATTRIBUTES DEFAULT, STDCALL, ALIAS : '_SafeArrayCreate@12' :: SafeArrayCreate
!DEC\$ELSE
!DEC\$ ATTRIBUTES DEFAULT, STDCALL, ALIAS : 'SafeArrayCreate' :: SafeArrayCreate
!DEC\$ENDIF
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
SEQUENCE
INTEGER*4       extent
INTEGER*4   lbound
END TYPE SA_BOUNDS
```

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,
SAFEARRRAYBOUND FAR* rgsabound );
```

Can anybody help me how to define a multidimension safearray?

thankyou!

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

Declare the interface with

```...
TYPE(SA_BOUNDS), INTENT(IN)         :: ab(dDims)
!DEC\$ ATTRIBUTES REFERENCE          :: ab
...
```

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!

If that interface were used to call a Fortran subroutine (your are not)
.AND.
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