May 6th, 2003, 11:47 am
Thank you, guys. Storing and passing the address of the range is actually recommended by MS. But I do not want to display a big array in the spreadsheet. It's not necessary and traders do not have to read and change the array. My current solution is to use C# Marshal methods (AllocCoTaskMem and Copy) to return an IntPtr. However, the Marshal method can only return an IntPtr to a one-dimensional array and my array is two-dimensional. So I generate an IntPtr for each column and then return an IntPtr to these IntPtr's. When I call the array, I pass the IntPtr to my function, get the array of IntPtr's and through them access the array output. This works. But I am not sure whether there's any memeory problems and if any, how to resolve them. Calling AllocCoTaskMem requiring calling FreeCoTaskMem to release the memeory. I am not sure when to free the memeory. Thanks again for your suggestions.