Renamed win32 to generic 32.

This commit is contained in:
Eugene Wang
2018-11-15 19:46:18 -05:00
parent e627615e1d
commit 546b885a0f
14 changed files with 77 additions and 73 deletions

View File

@@ -1,12 +1,13 @@
# TWAIN Application-Side Library
# TWAIN Application-Library
## Info
This is a library created to make working with [TWAIN](http://twain.org/) interface possible in dotnet.
This is a library created to make working with
[TWAIN](http://twain.org/) easier in dotnet.
This project has these features/goals:
* Targets latest TWAIN version (2.4 as of this writing)
* Supports all the TWAIN functions in the spec.
* Supports all the TWAIN functions in the spec (may never happen but will be close).
## Using the lib

View File

@@ -9,7 +9,7 @@ namespace NTwain.Triplets.Control
public ReturnCode RegisterCallback(ref TW_CALLBACK callback)
{
return NativeMethods.DsmWin32(Session.Config.AppWin32, Session.CurrentSource.Identity,
return NativeMethods.Dsm32(Session.Config.App32, Session.CurrentSource.Identity,
DataGroups.Control, DataArgumentType.Callback, Message.RegisterCallback, ref callback);
}
}

View File

@@ -9,7 +9,7 @@ namespace NTwain.Triplets.Control
public ReturnCode RegisterCallback(ref TW_CALLBACK2 callback)
{
return NativeMethods.DsmWin32(Session.Config.AppWin32, Session.CurrentSource.Identity,
return NativeMethods.Dsm32(Session.Config.App32, Session.CurrentSource.Identity,
DataGroups.Control, DataArgumentType.Callback2, Message.RegisterCallback, ref callback);
}
}

View File

@@ -9,7 +9,7 @@ namespace NTwain.Triplets.Control
public ReturnCode Get(ref TW_DEVICEEVENT sourceDeviceEvent)
{
return NativeMethods.DsmWin32(Session.Config.AppWin32, Session.CurrentSource.Identity,
return NativeMethods.Dsm32(Session.Config.App32, Session.CurrentSource.Identity,
DataGroups.Control, DataArgumentType.DeviceEvent, Message.Get, ref sourceDeviceEvent);
}
}

View File

@@ -13,7 +13,7 @@ namespace NTwain.Triplets.Control
public ReturnCode Get(out TW_ENTRYPOINT entryPoint)
{
entryPoint = new TW_ENTRYPOINT();
return NativeMethods.DsmWin32(Session.Config.AppWin32, null,
return NativeMethods.Dsm32(Session.Config.App32, null,
DataGroups.Control, DataArgumentType.EntryPoint, Message.Get, entryPoint);
}
}

View File

@@ -10,7 +10,7 @@ namespace NTwain.Triplets.Control
public ReturnCode CloseDS(TW_IDENTITY source)
{
var rc = NativeMethods.DsmWin32(Session.Config.AppWin32, IntPtr.Zero,
var rc = NativeMethods.Dsm32(Session.Config.App32, IntPtr.Zero,
DataGroups.Control, DataArgumentType.Identity, Message.CloseDS, source);
if (rc == ReturnCode.Success)
{
@@ -23,7 +23,7 @@ namespace NTwain.Triplets.Control
public ReturnCode GetDefault(out TW_IDENTITY source)
{
source = new TW_IDENTITY();
return NativeMethods.DsmWin32(Session.Config.AppWin32, IntPtr.Zero,
return NativeMethods.Dsm32(Session.Config.App32, IntPtr.Zero,
DataGroups.Control, DataArgumentType.Identity, Message.GetDefault, source);
}
@@ -31,14 +31,14 @@ namespace NTwain.Triplets.Control
public ReturnCode GetFirst(out TW_IDENTITY source)
{
source = new TW_IDENTITY();
return NativeMethods.DsmWin32(Session.Config.AppWin32, IntPtr.Zero,
return NativeMethods.Dsm32(Session.Config.App32, IntPtr.Zero,
DataGroups.Control, DataArgumentType.Identity, Message.GetFirst, source);
}
public ReturnCode GetNext(out TW_IDENTITY source)
{
source = new TW_IDENTITY();
return NativeMethods.DsmWin32(Session.Config.AppWin32, IntPtr.Zero,
return NativeMethods.Dsm32(Session.Config.App32, IntPtr.Zero,
DataGroups.Control, DataArgumentType.Identity, Message.GetNext, source);
}
@@ -46,7 +46,7 @@ namespace NTwain.Triplets.Control
{
Session.StepDown(TwainState.DsmOpened);
var rc = NativeMethods.DsmWin32(Session.Config.AppWin32, IntPtr.Zero,
var rc = NativeMethods.Dsm32(Session.Config.App32, IntPtr.Zero,
DataGroups.Control, DataArgumentType.Identity, Message.OpenDS, source);
if (rc == ReturnCode.Success)
{
@@ -59,14 +59,14 @@ namespace NTwain.Triplets.Control
public ReturnCode Set(DataSource source)
{
return NativeMethods.DsmWin32(Session.Config.AppWin32, IntPtr.Zero,
return NativeMethods.Dsm32(Session.Config.App32, IntPtr.Zero,
DataGroups.Control, DataArgumentType.Identity, Message.Set, source?.Identity);
}
public ReturnCode UserSelect(out TW_IDENTITY source)
{
source = new TW_IDENTITY();
return NativeMethods.DsmWin32(Session.Config.AppWin32, IntPtr.Zero,
return NativeMethods.Dsm32(Session.Config.App32, IntPtr.Zero,
DataGroups.Control, DataArgumentType.Identity, Message.UserSelect, source);
}
}

View File

@@ -12,14 +12,14 @@ namespace NTwain.Triplets.Control
public ReturnCode OpenDSM(IntPtr hWnd)
{
var rc = NativeMethods.DsmWin32(Session.Config.AppWin32, null,
var rc = NativeMethods.Dsm32(Session.Config.App32, null,
DataGroups.Control, DataArgumentType.Parent, Message.OpenDSM, ref hWnd);
if (rc == ReturnCode.Success)
{
Session.State = TwainState.DsmOpened;
// if twain2 then get memory management functions
if ((Session.Config.AppWin32.DataFunctionalities & DataFunctionalities.Dsm2) == DataFunctionalities.Dsm2)
if ((Session.Config.App32.DataFunctionalities & DataFunctionalities.Dsm2) == DataFunctionalities.Dsm2)
{
rc = Session.DGControl.EntryPoint.Get(out TW_ENTRYPOINT entry);
if (rc == ReturnCode.Success)
@@ -37,7 +37,7 @@ namespace NTwain.Triplets.Control
public ReturnCode CloseDSM(IntPtr hWnd)
{
var rc = NativeMethods.DsmWin32(Session.Config.AppWin32, null, DataGroups.Control,
var rc = NativeMethods.Dsm32(Session.Config.App32, null, DataGroups.Control,
DataArgumentType.Parent, Message.CloseDSM, ref hWnd);
if (rc == ReturnCode.Success) Session.State = TwainState.DsmLoaded;
return rc;

View File

@@ -9,13 +9,13 @@ namespace NTwain.Triplets.Control
public ReturnCode GetManagerStatus(ref TW_STATUS status)
{
return NativeMethods.DsmWin32(Session.Config.AppWin32, null,
return NativeMethods.Dsm32(Session.Config.App32, null,
DataGroups.Control, DataArgumentType.Status, Message.Get, ref status);
}
public ReturnCode GetSourceStatus(ref TW_STATUS status)
{
return NativeMethods.DsmWin32(Session.Config.AppWin32, Session.CurrentSource.Identity,
return NativeMethods.Dsm32(Session.Config.App32, Session.CurrentSource.Identity,
DataGroups.Control, DataArgumentType.Status, Message.Get, ref status);
}
}

View File

@@ -1,16 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
namespace NTwain.Triplets
{
/// <summary>
/// Provides direct access to the triplet call.
/// </summary>
public partial class DGCustom : BaseTriplet
{
internal DGCustom(TwainSession session) : base(session) { }
//namespace NTwain.Triplets
//{
// /// <summary>
// /// Provides direct access to the triplet call.
// /// </summary>
// public partial class DGCustom : BaseTriplet
// {
// internal DGCustom(TwainSession session) : base(session) { }
}
}
// }
//}

View File

@@ -10,7 +10,7 @@ namespace NTwain.Triplets
static partial class NativeMethods
{
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -19,7 +19,7 @@ namespace NTwain.Triplets
ref IntPtr data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -28,7 +28,7 @@ namespace NTwain.Triplets
ref DataGroups data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -37,7 +37,7 @@ namespace NTwain.Triplets
ref TW_AUDIOINFO data);
//[DllImport(DSM.WinDsmDll, EntryPoint = DSM.EntryName)]
//public static extern ReturnCode DsmWin32(
//public static extern ReturnCode Dsm32(
// [In, Out]TW_IDENTITY origin,
// [In, Out]TW_IDENTITY destination,
// DataGroups dg,
@@ -46,7 +46,7 @@ namespace NTwain.Triplets
// ref TWCapability data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -55,7 +55,7 @@ namespace NTwain.Triplets
ref TW_CUSTOMDSDATA data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -64,7 +64,7 @@ namespace NTwain.Triplets
ref TW_DEVICEEVENT data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -73,7 +73,7 @@ namespace NTwain.Triplets
ref TW_CALLBACK data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -82,7 +82,7 @@ namespace NTwain.Triplets
ref TW_CALLBACK2 data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -91,7 +91,7 @@ namespace NTwain.Triplets
[In, Out]TW_ENTRYPOINT data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -100,7 +100,7 @@ namespace NTwain.Triplets
ref TW_EVENT data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -109,7 +109,7 @@ namespace NTwain.Triplets
ref TW_FILESYSTEM data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
IntPtr zero,
DataGroups dg,
@@ -118,7 +118,7 @@ namespace NTwain.Triplets
[In, Out]TW_IDENTITY data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -127,7 +127,7 @@ namespace NTwain.Triplets
ref TW_PASSTHRU data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -136,7 +136,7 @@ namespace NTwain.Triplets
ref TW_PENDINGXFERS data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -145,7 +145,7 @@ namespace NTwain.Triplets
ref TW_SETUPFILEXFER data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -154,7 +154,7 @@ namespace NTwain.Triplets
ref TW_SETUPMEMXFER data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -163,7 +163,7 @@ namespace NTwain.Triplets
ref TW_STATUSUTF8 data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -172,7 +172,7 @@ namespace NTwain.Triplets
ref TW_USERINTERFACE data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -181,7 +181,7 @@ namespace NTwain.Triplets
ref TW_CIECOLOR data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -190,7 +190,7 @@ namespace NTwain.Triplets
ref TW_EXTIMAGEINFO data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -199,7 +199,7 @@ namespace NTwain.Triplets
ref TW_FILTER data);
//[DllImport(DSM.WinDsmDll, EntryPoint = DSM.EntryName)]
//public static extern ReturnCode DsmWin32(
//public static extern ReturnCode Dsm32(
// [In, Out]TW_IDENTITY origin,
// [In, Out]TW_IDENTITY destination,
// DataGroups dg,
@@ -208,7 +208,7 @@ namespace NTwain.Triplets
// ref TWGrayResponse data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -217,7 +217,7 @@ namespace NTwain.Triplets
ref TW_IMAGEINFO data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -226,7 +226,7 @@ namespace NTwain.Triplets
ref TW_IMAGELAYOUT data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -235,7 +235,7 @@ namespace NTwain.Triplets
ref TW_IMAGEMEMXFER data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -244,7 +244,7 @@ namespace NTwain.Triplets
ref TW_JPEGCOMPRESSION data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -253,7 +253,7 @@ namespace NTwain.Triplets
ref TW_PALETTE8 data);
//[DllImport(DSM.WinDsmDll, EntryPoint = DSM.EntryName)]
//public static extern ReturnCode DsmWin32(
//public static extern ReturnCode Dsm32(
// [In, Out]TW_IDENTITY origin,
// [In, Out]TW_IDENTITY destination,
// DataGroups dg,
@@ -262,7 +262,7 @@ namespace NTwain.Triplets
// ref TWRgbResponse data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
@@ -271,7 +271,7 @@ namespace NTwain.Triplets
ref TW_STATUS data);
[DllImport(WinDsmDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
public static extern ReturnCode Dsm32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,

View File

@@ -28,9 +28,12 @@ namespace NTwain
//public bool PreferLegacyDsm { get; internal set; }
internal TW_IDENTITY AppWin32 { get; set; }
/// <summary>
/// 32bit version of the app identity.
/// </summary>
internal TW_IDENTITY App32 { get; set; }
internal TW_IDENTITY SrcWin32 { get; set; }
//internal TW_IDENTITY Src32 { get; set; }
/// <summary>
/// Gets memory manager associated with a <see cref="TwainSession"/>.

View File

@@ -116,7 +116,7 @@ namespace NTwain
{
case PlatformID.Win32NT:
config.MemoryManager = new WinMemoryManager(); // initial default
config.AppWin32 = new TW_IDENTITY
config.App32 = new TW_IDENTITY
{
DataFunctionalities = DataFunctionalities.App2,
DataGroup = DataGroups.Control | _dg,

View File

@@ -42,10 +42,10 @@ namespace NTwain
/// </summary>
public DGAudio DGAudio => dgAudio ?? (dgAudio = new DGAudio(this));
/// <summary>
/// Gets/sets the direct triplet operation entry for custom values.
/// </summary>
public DGCustom DGCustom { get; set; }
///// <summary>
///// Gets/sets the direct triplet operation entry for custom values.
///// </summary>
//public DGCustom DGCustom { get; set; }
/// <summary>

View File

@@ -41,7 +41,7 @@ namespace NTwain
case PlatformID.MacOSX:
case PlatformID.Unix:
default:
_callbackDelegate = new CallbackDelegate(HandleWin32Callback);
_callbackDelegate = new CallbackDelegate(Handle32BitCallback);
break;
}
}
@@ -214,10 +214,10 @@ namespace NTwain
return source;
}
ReturnCode HandleWin32Callback(TW_IDENTITY origin, TW_IDENTITY destination,
ReturnCode Handle32BitCallback(TW_IDENTITY origin, TW_IDENTITY destination,
DataGroups dg, DataArgumentType dat, Message msg, IntPtr data)
{
Debug.WriteLine($"Thread {Thread.CurrentThread.ManagedThreadId}: {nameof(HandleWin32Callback)}({dg}, {dat}, {msg}, {data})");
Debug.WriteLine($"Thread {Thread.CurrentThread.ManagedThreadId}: {nameof(Handle32BitCallback)}({dg}, {dat}, {msg}, {data})");
HandleSourceMsg(msg);
return ReturnCode.Success;
}