Attempt to resurrect my old triplet ideas with new data types and native methods.

This commit is contained in:
Eugene Wang
2023-04-01 12:57:07 -04:00
parent 260ae9fdef
commit e68525775d
17 changed files with 479 additions and 10 deletions

View File

@@ -2,11 +2,11 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFrameworks>net462;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<PlatformTarget>x86</PlatformTarget>
<RootNamespace>SampleConsole</RootNamespace>
<LangVersion>11</LangVersion>
</PropertyGroup>
<ItemGroup>

View File

@@ -1,5 +1,8 @@
using NTwain;
using System;
using System.Diagnostics;
using System.Reflection;
using TWAINWorkingGroup;
namespace SampleConsole
{
@@ -7,8 +10,20 @@ namespace SampleConsole
{
static void Main(string[] args)
{
var twain = new TwainSession(Environment.ProcessPath ?? Assembly.GetExecutingAssembly().Location);
TwainPlatform.PreferLegacyDSM = true;
var twain = new TwainSession(Assembly.GetExecutingAssembly().Location);
twain.StateChanged += Twain_StateChanged;
var hwnd = IntPtr.Zero;
var rc = twain.DGControl.Parent.OpenDSM(ref hwnd);
Debug.WriteLine($"OpenDSM={rc}");
if (rc == TWAINWorkingGroup.STS.SUCCESS)
{
Debug.WriteLine($"CloseDSM={rc}");
rc = twain.DGControl.Parent.CloseDSM(ref hwnd);
}
}
private static void Twain_StateChanged(TwainSession session, TWAINWorkingGroup.STATE state)