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