void flxActCommonHandleGetError(FlxActHandle handle, FlxActError *err); private static extern void flxActCommonHandleGetError(handle, out ActivationError error);
It could have been an out param if err was FlxActError** but since it's not you probably have to allocate the structure and pass it by reference like that: private static extern void flxActCommonHandleGetError(IntPtr handle, ref ActivationError error); public ActivationError GetLastError() { ActivationError error = new ActivationError(); flxActCommonHandleGetError(Handle, ref error); return error; } Haven't tried it though. On 4/25/07, Mont Rothstein <[EMAIL PROTECTED]> wrote:
I am trying to get a struct from a function in a DLL, but I always get zero. The below code always leaves the struct with 0 as the value for each parameter in the struct though the equivalent C code populates the values. Does anyone see what I am missing? Thanks, -Mont Here is what I have: C definitions: typedef struct { uint32_t majorErrorNo; uint32_t minorErrorNo; uint32_t sysErrorNo; } FlxActError; void flxActCommonHandleGetError(FlxActHandle handle, FlxActError *err); public struct ActivationError { public uint majorError; public uint minorErrorNo; public uint systemErrorNo; } C# definition and function call: [DllImport("mydll.dll", CharSet = CharSet.Ansi)] private static extern void flxActCommonHandleGetError(handle, out ActivationError error); public ActivationError GetLastError() { ActivationError error; flxActCommonHandleGetError(Handle, out error); return error; } =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
-- Cheers, Stoyan =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com