Home › Forums › TWAIN Classic › Managed Data Source – .NET
- This topic has 2 replies, 1 voice, and was last updated 14 years, 11 months ago by michaellwest.
- AuthorPosts
Is it possible to write a datasource using C#?
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?
I did infact get past the previous problem. My data source now appears in the selection fine. The next issue I have encountered is when an Event occurs after OpenDS it gets stuck in a loop for DSEvent. How do I handle a DSEvent or any event for that matter?
- AuthorPosts