mirror of
https://github.com/soukoku/ntwain.git
synced 2025-11-24 16:53:24 +08:00
Fix sample not using correct scanner.
This commit is contained in:
@@ -32,7 +32,7 @@ namespace Net5Console
|
||||
{
|
||||
Console.WriteLine($"Transfer ready, count={e.PendingCount}.");
|
||||
};
|
||||
session.SourceDisabled += (sender,e)=>
|
||||
session.SourceDisabled += (sender, e) =>
|
||||
{
|
||||
Console.WriteLine("Disabled device.");
|
||||
Console.WriteLine();
|
||||
@@ -49,18 +49,24 @@ namespace Net5Console
|
||||
Console.WriteLine();
|
||||
|
||||
Console.WriteLine("All devices:");
|
||||
TW_IDENTITY dsToUse = default;
|
||||
TW_IDENTITY? dsToUse = null;
|
||||
foreach (var dev in session.GetDataSources())
|
||||
{
|
||||
Console.WriteLine($"\t{dev}");
|
||||
if (dev.ProductName == "TWAIN2 FreeImage Software Scanner")
|
||||
if (dev.ProductName == "TWAIN2 Software Scanner")
|
||||
{
|
||||
dsToUse = dev;
|
||||
}
|
||||
}
|
||||
Console.WriteLine();
|
||||
|
||||
session.CurrentDataSource = dsToUse;
|
||||
if (!dsToUse.HasValue)
|
||||
{
|
||||
Console.WriteLine("Sample scanner not found.");
|
||||
}
|
||||
else
|
||||
{
|
||||
session.CurrentDataSource = dsToUse.Value;
|
||||
if (session.CurrentDataSource.HasValue)
|
||||
{
|
||||
Console.WriteLine("Current device after opening attempt:");
|
||||
@@ -75,10 +81,11 @@ namespace Net5Console
|
||||
}
|
||||
Console.WriteLine();
|
||||
|
||||
var sts = caps.CAP_XFERCOUNT.SetOrConstraint(MSG.SET, 2);
|
||||
short count = 3;
|
||||
var sts = caps.CAP_XFERCOUNT.SetOrConstraint(MSG.SET, count);
|
||||
if (sts == STS.SUCCESS)
|
||||
{
|
||||
Console.WriteLine("Successfully set xfercount to 2.");
|
||||
Console.WriteLine($"Successfully set xfercount to {count}.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -118,6 +125,7 @@ namespace Net5Console
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Error.WriteLine("Failed to open DSM");
|
||||
|
||||
Reference in New Issue
Block a user