在 C# 和 .NET 中使用 TWAIN 进行扫描仪的检测,可以使用以下步骤:
private static void RegisterScanner(TwainRegistryManager mgr)
{
var properties = new[]
{
new VendorId PropertyName { VendorId = 0x0002, PropertyName = "DeviceCapabilities" },
new PropertyName PropertyName { PropertyName = "Name" },
new ProductId PropertyName { ProductId = 0x0903, PropertyName = "ProductName" },
new ProductName PropertyName { PropertyName = "DeviceName" }
};
mgr.RegisterDevice(properties, 1, false);
mgr.Initialize();
}
ScannerDialog
的控件,用于展示扫描仪选项,并设置扫描仪的设备特征:using System;
using System.Collections.Generic;
using System.Windows.Forms;
using TWAIN.ImageSource;
// 自定义扫描仪选项列表
private List<IScanSource> scannerOptions = new List<IScanSource>()
{
new TWAIN.ImageDevice.ClientInfo()
{
Connect = () =>
{
var mgr = new TwainRegistryManager(new Dictionary<uint, string>() {
{ (uint)PropertyId.VendorId, "MINICOM">
领取专属 10元无门槛券
手把手带您无忧上云