mirror of
https://github.com/soukoku/ntwain.git
synced 2025-11-24 16:53:24 +08:00
Made entrypoint call work with platform checks.
This commit is contained in:
@@ -12,7 +12,7 @@ namespace NTwain.Triplets.Control
|
|||||||
if (Use32BitData)
|
if (Use32BitData)
|
||||||
{
|
{
|
||||||
return NativeMethods.Dsm32(Session.Config.App32, Session.CurrentSource.Identity,
|
return NativeMethods.Dsm32(Session.Config.App32, Session.CurrentSource.Identity,
|
||||||
DataGroups.Control, DataArgumentType.Callback2, Message.RegisterCallback, ref callback);
|
DataGroups.Control, DataArgumentType.Callback2, Message.RegisterCallback, ref callback);
|
||||||
}
|
}
|
||||||
return ReturnCode.Failure;
|
return ReturnCode.Failure;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace NTwain.Triplets.Control
|
|||||||
if (Use32BitData)
|
if (Use32BitData)
|
||||||
{
|
{
|
||||||
return NativeMethods.Dsm32(Session.Config.App32, Session.CurrentSource.Identity,
|
return NativeMethods.Dsm32(Session.Config.App32, Session.CurrentSource.Identity,
|
||||||
DataGroups.Control, DataArgumentType.DeviceEvent, Message.Get, ref sourceDeviceEvent);
|
DataGroups.Control, DataArgumentType.DeviceEvent, Message.Get, ref sourceDeviceEvent);
|
||||||
}
|
}
|
||||||
return ReturnCode.Failure;
|
return ReturnCode.Failure;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace NTwain.Triplets.Control
|
|||||||
if (Use32BitData)
|
if (Use32BitData)
|
||||||
{
|
{
|
||||||
return NativeMethods.Dsm32(Session.Config.App32, null,
|
return NativeMethods.Dsm32(Session.Config.App32, null,
|
||||||
DataGroups.Control, DataArgumentType.EntryPoint, Message.Get, entryPoint);
|
DataGroups.Control, DataArgumentType.EntryPoint, Message.Get, entryPoint);
|
||||||
}
|
}
|
||||||
return ReturnCode.Failure;
|
return ReturnCode.Failure;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace NTwain.Triplets.Control
|
|||||||
if (Use32BitData)
|
if (Use32BitData)
|
||||||
{
|
{
|
||||||
rc = NativeMethods.Dsm32(Session.Config.App32, IntPtr.Zero,
|
rc = NativeMethods.Dsm32(Session.Config.App32, IntPtr.Zero,
|
||||||
DataGroups.Control, DataArgumentType.Identity, Message.CloseDS, source);
|
DataGroups.Control, DataArgumentType.Identity, Message.CloseDS, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc == ReturnCode.Success)
|
if (rc == ReturnCode.Success)
|
||||||
@@ -32,7 +32,7 @@ namespace NTwain.Triplets.Control
|
|||||||
if (Use32BitData)
|
if (Use32BitData)
|
||||||
{
|
{
|
||||||
return NativeMethods.Dsm32(Session.Config.App32, IntPtr.Zero,
|
return NativeMethods.Dsm32(Session.Config.App32, IntPtr.Zero,
|
||||||
DataGroups.Control, DataArgumentType.Identity, Message.GetDefault, source);
|
DataGroups.Control, DataArgumentType.Identity, Message.GetDefault, source);
|
||||||
}
|
}
|
||||||
return ReturnCode.Failure;
|
return ReturnCode.Failure;
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ namespace NTwain.Triplets.Control
|
|||||||
if (Use32BitData)
|
if (Use32BitData)
|
||||||
{
|
{
|
||||||
return NativeMethods.Dsm32(Session.Config.App32, IntPtr.Zero,
|
return NativeMethods.Dsm32(Session.Config.App32, IntPtr.Zero,
|
||||||
DataGroups.Control, DataArgumentType.Identity, Message.GetFirst, source);
|
DataGroups.Control, DataArgumentType.Identity, Message.GetFirst, source);
|
||||||
}
|
}
|
||||||
return ReturnCode.Failure;
|
return ReturnCode.Failure;
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ namespace NTwain.Triplets.Control
|
|||||||
if (Use32BitData)
|
if (Use32BitData)
|
||||||
{
|
{
|
||||||
rc = NativeMethods.Dsm32(Session.Config.App32, IntPtr.Zero,
|
rc = NativeMethods.Dsm32(Session.Config.App32, IntPtr.Zero,
|
||||||
DataGroups.Control, DataArgumentType.Identity, Message.OpenDS, source);
|
DataGroups.Control, DataArgumentType.Identity, Message.OpenDS, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc == ReturnCode.Success)
|
if (rc == ReturnCode.Success)
|
||||||
@@ -81,7 +81,7 @@ namespace NTwain.Triplets.Control
|
|||||||
if (Use32BitData)
|
if (Use32BitData)
|
||||||
{
|
{
|
||||||
return NativeMethods.Dsm32(Session.Config.App32, IntPtr.Zero,
|
return NativeMethods.Dsm32(Session.Config.App32, IntPtr.Zero,
|
||||||
DataGroups.Control, DataArgumentType.Identity, Message.Set, source?.Identity);
|
DataGroups.Control, DataArgumentType.Identity, Message.Set, source?.Identity);
|
||||||
}
|
}
|
||||||
return ReturnCode.Failure;
|
return ReturnCode.Failure;
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ namespace NTwain.Triplets.Control
|
|||||||
if (Use32BitData)
|
if (Use32BitData)
|
||||||
{
|
{
|
||||||
return NativeMethods.Dsm32(Session.Config.App32, IntPtr.Zero,
|
return NativeMethods.Dsm32(Session.Config.App32, IntPtr.Zero,
|
||||||
DataGroups.Control, DataArgumentType.Identity, Message.UserSelect, source);
|
DataGroups.Control, DataArgumentType.Identity, Message.UserSelect, source);
|
||||||
}
|
}
|
||||||
return ReturnCode.Failure;
|
return ReturnCode.Failure;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,28 +14,28 @@ namespace NTwain.Triplets.Control
|
|||||||
{
|
{
|
||||||
var rc = ReturnCode.Failure;
|
var rc = ReturnCode.Failure;
|
||||||
|
|
||||||
|
bool isDsm2 = false;
|
||||||
|
|
||||||
if (Use32BitData)
|
if (Use32BitData)
|
||||||
{
|
{
|
||||||
rc = NativeMethods.Dsm32(Session.Config.App32, null,
|
rc = NativeMethods.Dsm32(Session.Config.App32, null,
|
||||||
DataGroups.Control, DataArgumentType.Parent, Message.OpenDSM, ref hWnd);
|
DataGroups.Control, DataArgumentType.Parent, Message.OpenDSM, ref hWnd);
|
||||||
|
|
||||||
|
isDsm2 = rc == ReturnCode.Success &&
|
||||||
|
(Session.Config.App32.DataFunctionalities & DataFunctionalities.Dsm2) == DataFunctionalities.Dsm2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc == ReturnCode.Success)
|
if (rc == ReturnCode.Success)
|
||||||
{
|
{
|
||||||
Session.State = TwainState.DsmOpened;
|
Session.State = TwainState.DsmOpened;
|
||||||
|
|
||||||
// if twain2 then get memory management functions
|
if (isDsm2)
|
||||||
if ((Session.Config.App32.DataFunctionalities & DataFunctionalities.Dsm2) == DataFunctionalities.Dsm2)
|
|
||||||
{
|
{
|
||||||
rc = Session.DGControl.EntryPoint.Get(out TW_ENTRYPOINT entry);
|
rc = Session.DGControl.EntryPoint.Get(out TW_ENTRYPOINT entry);
|
||||||
if (rc == ReturnCode.Success)
|
if (rc == ReturnCode.Success)
|
||||||
{
|
{
|
||||||
Session.Config.MemoryManager = entry;
|
Session.Config.MemoryManager = entry;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
rc = CloseDSM(hWnd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
@@ -48,11 +48,12 @@ namespace NTwain.Triplets.Control
|
|||||||
if (Use32BitData)
|
if (Use32BitData)
|
||||||
{
|
{
|
||||||
rc = NativeMethods.Dsm32(Session.Config.App32, null, DataGroups.Control,
|
rc = NativeMethods.Dsm32(Session.Config.App32, null, DataGroups.Control,
|
||||||
DataArgumentType.Parent, Message.CloseDSM, ref hWnd);
|
DataArgumentType.Parent, Message.CloseDSM, ref hWnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc == ReturnCode.Success)
|
if (rc == ReturnCode.Success)
|
||||||
{
|
{
|
||||||
|
Session.Config.MemoryManager = null;
|
||||||
Session.State = TwainState.DsmLoaded;
|
Session.State = TwainState.DsmLoaded;
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
|
|||||||
@@ -9,14 +9,22 @@ namespace NTwain.Triplets.Control
|
|||||||
|
|
||||||
public ReturnCode GetManagerStatus(ref TW_STATUS status)
|
public ReturnCode GetManagerStatus(ref TW_STATUS status)
|
||||||
{
|
{
|
||||||
return NativeMethods.Dsm32(Session.Config.App32, null,
|
if (Use32BitData)
|
||||||
DataGroups.Control, DataArgumentType.Status, Message.Get, ref status);
|
{
|
||||||
|
return NativeMethods.Dsm32(Session.Config.App32, null,
|
||||||
|
DataGroups.Control, DataArgumentType.Status, Message.Get, ref status);
|
||||||
|
}
|
||||||
|
return ReturnCode.Failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReturnCode GetSourceStatus(ref TW_STATUS status)
|
public ReturnCode GetSourceStatus(ref TW_STATUS status)
|
||||||
{
|
{
|
||||||
return NativeMethods.Dsm32(Session.Config.App32, Session.CurrentSource.Identity,
|
if (Use32BitData)
|
||||||
DataGroups.Control, DataArgumentType.Status, Message.Get, ref status);
|
{
|
||||||
|
return NativeMethods.Dsm32(Session.Config.App32, Session.CurrentSource.Identity,
|
||||||
|
DataGroups.Control, DataArgumentType.Status, Message.Get, ref status);
|
||||||
|
}
|
||||||
|
return ReturnCode.Failure;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,9 +35,19 @@ namespace NTwain
|
|||||||
|
|
||||||
//internal TW_IDENTITY Src32 { get; set; }
|
//internal TW_IDENTITY Src32 { get; set; }
|
||||||
|
|
||||||
|
IMemoryManager _memMgr;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets memory manager associated with a <see cref="TwainSession"/>.
|
/// Gets memory manager associated with a <see cref="TwainSession"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IMemoryManager MemoryManager { get; internal set; }
|
public IMemoryManager MemoryManager
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _memMgr ?? DefaultMemoryManager;
|
||||||
|
}
|
||||||
|
internal set { _memMgr = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal IMemoryManager DefaultMemoryManager { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ namespace NTwain
|
|||||||
switch (_platform)
|
switch (_platform)
|
||||||
{
|
{
|
||||||
case PlatformID.Win32NT:
|
case PlatformID.Win32NT:
|
||||||
config.MemoryManager = new WinMemoryManager(); // initial default
|
config.DefaultMemoryManager = new WinMemoryManager(); // initial default
|
||||||
config.App32 = new TW_IDENTITY
|
config.App32 = new TW_IDENTITY
|
||||||
{
|
{
|
||||||
DataFunctionalities = DataFunctionalities.App2,
|
DataFunctionalities = DataFunctionalities.App2,
|
||||||
|
|||||||
Reference in New Issue
Block a user