159 lines
6.5 KiB
C#
159 lines
6.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace WindowsFormsApp1
|
|
{
|
|
public class HGScannerLib
|
|
{
|
|
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
|
public struct HGLibSaveImageParam
|
|
{
|
|
public UInt32 size;
|
|
public UInt32 jpegQuality;
|
|
public UInt32 tiffCompression;
|
|
public UInt32 tiffJpegQuality;
|
|
public Int32 ocr;
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
|
public struct HGLibDeviceIntValueList
|
|
{
|
|
public IntPtr value; // Int32指针
|
|
public UInt32 count;
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
|
public struct HGLibDeviceEnumValueList
|
|
{
|
|
public IntPtr value; // UInt32指针
|
|
public UInt32 count;
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
|
public struct HGLibDeviceDoubleValueList
|
|
{
|
|
public IntPtr value; // Double指针
|
|
public UInt32 count;
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
|
public struct HGLibDeviceIntValueRange
|
|
{
|
|
public Int32 minValue;
|
|
public Int32 maxValue;
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
|
public struct HGLibDeviceDoubleValueRange
|
|
{
|
|
public Double minValue;
|
|
public Double maxValue;
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Explicit, Pack = 4)]
|
|
public struct HGLibDeviceParamType
|
|
{
|
|
[FieldOffset(0)] public Int32 intValue;
|
|
[FieldOffset(0)] public UInt32 enumValue;
|
|
[FieldOffset(0)] public Double doubleValue;
|
|
[FieldOffset(0)] public Int32 boolValue;
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Explicit, Pack = 4)]
|
|
public struct HGLibDeviceParamRangeType
|
|
{
|
|
[FieldOffset(0)] public HGLibDeviceIntValueList intValueList;
|
|
[FieldOffset(0)] public HGLibDeviceEnumValueList enumValueList;
|
|
[FieldOffset(0)] public HGLibDeviceDoubleValueList doubleValueList;
|
|
[FieldOffset(0)] public HGLibDeviceIntValueRange intValueRange;
|
|
[FieldOffset(0)] public HGLibDeviceDoubleValueRange doubleValueRange;
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
|
public struct HGLibDeviceParam
|
|
{
|
|
public UInt32 option;
|
|
public UInt32 type;
|
|
public HGLibDeviceParamType typeValue;
|
|
public UInt32 rangeType;
|
|
public HGLibDeviceParamRangeType rangeTypeValue;
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
|
public struct HGLibDeviceParamGroup
|
|
{
|
|
public UInt32 group;
|
|
public IntPtr param; // HGLibDeviceParam指针
|
|
public UInt32 paramCount;
|
|
}
|
|
|
|
public delegate void HGLibDeviceHotPlugEventFunc(UInt32 evt, IntPtr deviceName, IntPtr param);
|
|
public delegate void HGLibDeviceScanEventFunc(UIntPtr device, UInt32 evt, Int32 err, IntPtr info, IntPtr param);
|
|
public delegate void HGLibDeviceScanImageFunc(UIntPtr device, UIntPtr image, IntPtr param);
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_LoadImage")]
|
|
public static extern UIntPtr HGLib_LoadImage(IntPtr filePath);
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_SaveImage")]
|
|
public static extern Int32 HGLib_SaveImage(UIntPtr image, IntPtr filePath, ref HGLibSaveImageParam saveParam);
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_ReleaseImage")]
|
|
public static extern Int32 HGLib_ReleaseImage(UIntPtr image);
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_InitDevice")]
|
|
public static extern Int32 HGLib_InitDevice(HGLibDeviceHotPlugEventFunc func, IntPtr param);
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_DeinitDevice")]
|
|
public static extern Int32 HGLib_DeinitDevice();
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_GetDeviceNameList")]
|
|
public static extern IntPtr HGLib_GetDeviceNameList();
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_ReleaseDeviceNameList")]
|
|
public static extern Int32 HGLib_ReleaseDeviceNameList(IntPtr deviceNameList);
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_OpenDevice")]
|
|
public static extern UIntPtr HGLib_OpenDevice(IntPtr deviceName);
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_CloseDevice")]
|
|
public static extern Int32 HGLib_CloseDevice(UIntPtr device);
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_GetDeviceSN")]
|
|
public static extern Int32 HGLib_GetDeviceSN(UIntPtr device, IntPtr sn, UInt32 maxLen);
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_GetDeviceFWVersion")]
|
|
public static extern Int32 HGLib_GetDeviceFWVersion(UIntPtr device, IntPtr fwVersion, UInt32 maxLen);
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_SetDeviceParam")]
|
|
public static extern Int32 HGLib_SetDeviceParam(UIntPtr device, UInt32 option, IntPtr data);
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_GetDeviceParamGroupList")]
|
|
public static extern IntPtr HGLib_GetDeviceParamGroupList(UIntPtr device, ref UInt32 count);
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_GetDeviceParam")]
|
|
public static extern IntPtr HGLib_GetDeviceParam(UIntPtr device, UInt32 option);
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_ReleaseDeviceParamGroupList")]
|
|
public static extern Int32 HGLib_ReleaseDeviceParamGroupList(IntPtr devParamGroup, UInt32 count);
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_ReleaseDeviceParam")]
|
|
public static extern Int32 HGLib_ReleaseDeviceParam(IntPtr devParam);
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_ResetDeviceParam")]
|
|
public static extern Int32 HGLib_ResetDeviceParam(UIntPtr device);
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_DeviceIsPaperOn")]
|
|
public static extern Int32 HGLib_DeviceIsPaperOn(UIntPtr device);
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_StartDeviceScan")]
|
|
public static extern Int32 HGLib_StartDeviceScan(UIntPtr device, HGLibDeviceScanEventFunc eventFunc, IntPtr eventParam,
|
|
HGLibDeviceScanImageFunc imageFunc, IntPtr imageParam);
|
|
|
|
[DllImport("HGScannerLib.dll", EntryPoint = "HGLib_StopDeviceScan")]
|
|
public static extern Int32 HGLib_StopDeviceScan(UIntPtr device);
|
|
}
|
|
}
|