Click to See Complete Forum and Search --> : HOW to pass ARRAY OF STRUCTURES in COM DYNAMICALLY thru interface methods


somasrini
May 25th, 1999, 02:10 AM
Can any body tell me how do i pass ARRAY OF STRUCTURES IN COM DYNAMICALLY FROM A outproc server to client.
eg..
I have a structure A { int x, float y, char z} of size [n] .. i would like to fire this data through my outgoing interface . Is there any way please
reply me.

srini s (somasrini@yahoo.com)

Marqy
May 25th, 1999, 03:45 AM
Look at COleSafeAray. You can create a 1 dimensional byte array COleSafeArray::CreateOneDim

copy your structure byte-per-byte into the array, then get the VARIANT out of the array using ColeSafeArray::Detach()

. You now have your structure in a VARIANT, which can be marshalled by both COM & DCOM. Also you have to free the memory allocated manually (since you called Detach()); call VariantClear() to do the job.

MJA