Add call to open DS in wrapper.

This commit is contained in:
Eugene Wang
2021-04-21 13:06:02 -04:00
parent 66b5270d37
commit 091470c0b0
5 changed files with 95 additions and 21 deletions

View File

@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\NTwain\NTwain.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,38 @@
using NTwain;
using System;
using System.Reflection;
namespace Net5Console
{
class Program
{
static void Main(string[] args)
{
using (var twain = new TwainSession(Assembly.GetExecutingAssembly(), null, IntPtr.Zero))
{
if (twain.Open() == TWAINWorkingGroup.STS.SUCCESS)
{
Console.WriteLine("Opened DSM");
Console.WriteLine("Default device:");
Console.WriteLine($"\t{twain.DefaultDevice}");
Console.WriteLine("All devices:");
foreach (var dev in twain.GetDevices())
{
Console.WriteLine($"\t{dev}");
}
Console.WriteLine("Current device:");
Console.WriteLine($"\t{twain.CurrentDevice}");
twain.CurrentDevice = twain.DefaultDevice;
Console.WriteLine("Current device after setting:");
Console.WriteLine($"\t{twain.CurrentDevice}");
}
else
{
Console.Error.WriteLine("Failed to open DSM");
}
Console.WriteLine("Test Ended");
}
}
}
}