mirror of
https://github.com/soukoku/ntwain.git
synced 2026-01-26 13:39:47 +08:00
Add call to open DS in wrapper.
This commit is contained in:
12
samples/Net5Console/Net5Console.csproj
Normal file
12
samples/Net5Console/Net5Console.csproj
Normal 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>
|
||||
38
samples/Net5Console/Program.cs
Normal file
38
samples/Net5Console/Program.cs
Normal 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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user