public Twain()
        {
            appid    = new TW_IDENTITY();
            appid.Id = IntPtr.Zero;
            appid.Version.MajorNum = 1;
            appid.Version.MinorNum = 0;
            appid.Version.Language = LanguageUSA;
            appid.Version.Country  = CountryUSA;
            appid.Version.Info     = "";
            appid.ProtocolMajor    = TwProtocol.Major;
            appid.ProtocolMinor    = TwProtocol.Minor;
            appid.SupportedGroups  = (int)(TwDG.Image | TwDG.Control);
            appid.Manufacturer     = "Bytescout Software";
            appid.ProductFamily    = "Development Tools";
            appid.ProductName      = "Scan SDK";

            srcds    = new TW_IDENTITY();
            srcds.Id = IntPtr.Zero;

            evtmsg.EventPtr = Marshal.AllocHGlobal(Marshal.SizeOf(winmsg));
        }
        public Twain()
        {
            appid = new TW_IDENTITY();
            appid.Id = IntPtr.Zero;
            appid.Version.MajorNum = 1;
            appid.Version.MinorNum = 0;
            appid.Version.Language = LanguageUSA;
            appid.Version.Country = CountryUSA;
            appid.Version.Info = "";
            appid.ProtocolMajor = TwProtocol.Major;
            appid.ProtocolMinor = TwProtocol.Minor;
            appid.SupportedGroups = (int) (TwDG.Image | TwDG.Control);
            appid.Manufacturer = "Bytescout Software";
            appid.ProductFamily = "Development Tools";
            appid.ProductName = "Scan SDK";

            srcds = new TW_IDENTITY();
            srcds.Id = IntPtr.Zero;

            evtmsg.EventPtr = Marshal.AllocHGlobal(Marshal.SizeOf(winmsg));
        }
 private static extern TwRC DSpxfer([In, Out] TW_IDENTITY origin, [In] TW_IDENTITY dest, TwDG dg, TwDAT dat, TwMSG msg, [In, Out] TW_PENDINGXFERS pxfr);
 private static extern TwRC DSiinf([In, Out] TW_IDENTITY origin, [In] TW_IDENTITY dest, TwDG dg, TwDAT dat, TwMSG msg, [In, Out] TW_IMAGEINFO imginf);
 private static extern TwRC DSixfer([In, Out] TW_IDENTITY origin, [In] TW_IDENTITY dest, TwDG dg, TwDAT dat, TwMSG msg, ref IntPtr hbitmap);
 private static extern TwRC DSstatus([In, Out] TW_IDENTITY origin, [In] TW_IDENTITY dest, TwDG dg, TwDAT dat, TwMSG msg, [In, Out] TW_STATUS dsmstat);
 private static extern TwRC DScap([In, Out] TW_IDENTITY origin, [In] TW_IDENTITY dest, TwDG dg, TwDAT dat, TwMSG msg, [In, Out] TwCapability capa);
 private static extern TwRC DSevent([In, Out] TW_IDENTITY origin, [In, Out] TW_IDENTITY dest, TwDG dg, TwDAT dat, TwMSG msg, ref TW_EVENT evt);
 private static extern TwRC DSuserif([In, Out] TW_IDENTITY origin, [In, Out] TW_IDENTITY dest, TwDG dg, TwDAT dat, TwMSG msg, TW_USERINTERFACE guif);
 private static extern TwRC DSMstatus([In, Out] TW_IDENTITY origin, IntPtr zeroptr, TwDG dg, TwDAT dat, TwMSG msg, [In, Out] TW_STATUS dsmstat);
 private static extern TwRC DSMident([In, Out] TW_IDENTITY origin, IntPtr zeroptr, TwDG dg, TwDAT dat, TwMSG msg, [In, Out] TW_IDENTITY idds);
 private static extern TwRC DSMparent([In, Out] TW_IDENTITY origin, IntPtr zeroptr, TwDG dg, TwDAT dat, TwMSG msg, ref IntPtr refptr);