Thomas,
That looks fine, the only thing is that I think that you ^might^ have to
add the MarshalAs attribute for the pointer itself, like this:
[StructLayout(LayoutKind.Sequential)]
public class LiffeResponseHandlerList
{
[MarshalAs(UnmanagedType.FunctionPtr)]
public OnAccessTransfer OnAccessTransfer;
}
I'm not sure if delegates are marshaled like this by default (although I
would assume they are). Also, if something is setting this structure up,
(assining the function pointer and returning it), I am not sure if .NET will
marshal it back correctly. I think in 2.0 it will do it correctly, while I
am unsure about 1.1 and before (it's easy enough to test).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mvp@spam.guard.caspershouse.com
"Thomas Connolly" <tomc@cqg.com> wrote in message
news:eKF3tvH6EHA.128@TK2MSFTNGP15.phx.gbl...[color=blue]
> Hello list,
> No one seems to be replying to my request on the interop group so I
> thought I would try here.
> Can someone please help me with this? I have a C struct containing
> function pointers like so:
>
> typedef struct _tagLiffeResponseHandlerList
> {
>
> void (*OnAccessTransfer) (LiffeStatus eStatus, const char* pszTrader,
> LiffeBoolean bContinuationFlag,
> int nNumOrders, const LiffeOrderEntryList* pcLiffeOrderEntryList,
> time_t nTimeStamp);
>
> ****** other function pointers omitted for brevity *******
>
> } LiffeResponseHandlerList;
>
> Would the following be correct?
>
> public delegate void OnAccessTransfer(LiffeStatus eStatus,
> [MarshalAs(UnmanagedType.LPStr)] string pszTrader, LiffeBoolean
> bContinuationFlag, int nNumOrders, ref LiffeOrderEntryList
> pcLiffeOrderEntryList, uint nTimeStamp);
>
> [StructLayout(LayoutKind.Sequential)]
> public class LiffeResponseHandlerList
> {
> public OnAccessTransfer OnAccessTransfer;
> }
>
> Thanks for the help
>
>[/color]