Home › Forums › TWAIN Classic › Managed Data Source – .NET › Reply To: Managed Data Source – .NET
Here is what I have so far (assume that I have already exported the function):
public static UInt16 DS_ENTRY(TwIdentity identity, TwDG dg, TwDAT dat,
TwMSG msg, ref IntPtr ptr) {}
where TwIdentity, TwDG, TwDAT, and TwMSG are structures.
Currently when I test using Twacker (Twack_32.exe) the above method is called. I have problems getting the identity to appear in the twain selection (it will eventually appear if I select another twain device and then open the selection again but the description is not correct).
This is what I do for Control -> Identity -> Get
int structSize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(TwIdentity));
ptr = System.Runtime.InteropServices.Marshal.AllocHGlobal(structSize);
System.Runtime.InteropServices.Marshal.StructureToPtr(identity, ptr, true);
based on the sample program on Sourceforge.net, the above lines are my attempt to replace memcpy.
Any suggestions on how to better implement this?