How to call a COM method that has SAFEARRARY

D

Dan Holmes

I have to call the following COM interface. Can i just pass a c# array
of longs and doubles? What about the out parameters? They need to be
preallocated. Can i build them of the appropriate size and send them as ref?


[id(11), helpstring("Calculate travel time and distance between
locations assuming given start or end time ")]
HRESULT CalculateTravelCosts(
[in] SAFEARRAY(long) *lOriginLocationIds,
[in] SAFEARRAY(long) *lOriginEdgeIds,
[in] SAFEARRAY(long) *lOriginEdgePercents,
[in] SAFEARRAY(double) *dOriginLongitudes,
[in] SAFEARRAY(double) *dOriginLatitudes,
[in] SAFEARRAY(long) *lDestinationLocationIds,
[in] SAFEARRAY(long) *lDestinationEdgeIds,
[in] SAFEARRAY(long) *lDestinationEdgePercents,
[in] SAFEARRAY(double) *dDestinationLongitudes,
[in] SAFEARRAY(double) *dDestinationLatitudes,
[in] SAFEARRAY(long) *lOffsetsAtLocationInMinutes,
[in] SAFEARRAY(long) *lOptionFlags,
[in, out] SAFEARRAY(long) *lComputedTravelTimes,
[in, out] SAFEARRAY(long) *lComputeTravelDistances);



thanks
danny
 
W

Wazza

I have to call the following COM interface.  Can i just pass a c# array
of longs and doubles?  What about the out parameters?  They need to be
preallocated.  Can i build them of the appropriate size and send them as ref?

[id(11), helpstring("Calculate travel time and distance between
locations assuming given start or end time  ")]
HRESULT CalculateTravelCosts(
[in] SAFEARRAY(long)               *lOriginLocationIds,
[in] SAFEARRAY(long)               *lOriginEdgeIds,
[in] SAFEARRAY(long)               *lOriginEdgePercents,
[in] SAFEARRAY(double)             *dOriginLongitudes,
[in] SAFEARRAY(double)             *dOriginLatitudes,
[in] SAFEARRAY(long)               *lDestinationLocationIds,
[in] SAFEARRAY(long)               *lDestinationEdgeIds,
[in] SAFEARRAY(long)               *lDestinationEdgePercents,
[in] SAFEARRAY(double)             *dDestinationLongitudes,
[in] SAFEARRAY(double)             *dDestinationLatitudes,
[in] SAFEARRAY(long)               *lOffsetsAtLocationInMinutes,
[in] SAFEARRAY(long)               *lOptionFlags,
[in, out] SAFEARRAY(long)          *lComputedTravelTimes,
[in, out] SAFEARRAY(long)        *lComputeTravelDistances);

thanks
danny

use system.Array see my reply to your other question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top