Hello,
You make wrong way wrapper for your
TMFirst
function. You should not use
byte[]
as argument without specifing size of the buffer. As your functiona declaration does not have size argument you should use
IntPtr
as input type. It should looks:
[DllImport("IBFS32.DLL", CallingConvention = CallingConvention.Winapi)]
public static extern int TMFirst(long sessionhandle, IntPtr statebuffer);
long _Handle;
byte[] _Statebuffer;
IntPtr _ptr = Marshal.AllocCoTaskMem(_Statebuffer.Length);
Marshal.Copy(_ptr,_Statebuffer,0,_Statebuffer.Length);
TMFirst(_Handle,_ptr);
Marshal.Copy(_Statebuffer,0,_ptr,_Statebuffer.Length);
Marshal.FreeCoTaskMem(_ptr);
Regards,
Maxim.