0

我有一个 Honeywell 4800P 条码扫描器,我在 Windows 7 64 位上下载并安装了 Intermec 1.6 SDK,我将 ISDC_PnP.dll、ISDC_RS.dll 和 ISDC_HID.dll 所有 64 位版本复制到 System32。

我已经正确安装了驱动程序,并且通过在另一台计算机上测试它来验证我的硬件工作正常,我的 USB 端口也通过尝试另一个 USB 设备正常工作。

现在我有了这个包装器:

enum DllErrorCode : ushort
{
    NO_ERROR = 0,
    INVALID_INPUT_BUFFER = 1,
    OUTPUT_BUFFER_TO_SMALL = 2,
    REGISTRY_ERROR = 3,
    ALLOCATION_ERROR = 4,
    RESERVED = 5,
    RESERVED1 = 6,
    DLL_NOT_INITIALIZED = 7,
    NO_DEVICE_FOUND = 8,
    INTERF_PORT_NOT_AVAILABLE = 9,
    CONNECTION_LOST = 10,
    OPERATION_CANCELLED = 11,
    INTERNAL_ERROR = 12,
    NOT_SUPPORTED = 13,
}
class IsdcWrapper
{
    #region Constantes
    const String DllName = "ISDC_PnP.dll";
    const UInt32 MaxStrLength = 1024;
    #endregion

    #region ImportDll

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport("user32", EntryPoint = "RegisterWindowMessage")]
    private static extern int _RegisterWindowMessage(string lpString);



    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "ConfigurationDialog", SetLastError = true,
         CharSet = CharSet.Unicode, ExactSpelling = true,
         CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _ConfigurationDialog();

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "Connect", SetLastError = true,
         CharSet = CharSet.Unicode, ExactSpelling = true,
         CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _Connect();

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "ControlCommand", SetLastError = true,
        CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _ControlCommand(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pInputBuffer,
                UInt32 nBytesInInputBuffer,
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "ControlPermissionRead", SetLastError = true,
        CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _ControlPermissionRead(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pInputBuffer,
                UInt32 nBytesInInputBuffer,
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "ControlPermissionWrite", SetLastError = true,
        CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _ControlPermissionWrite(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pInputBuffer,
                UInt32 nBytesInInputBuffer,
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "ControlRangeRead", SetLastError = true,
        CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _ControlRangeRead(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pInputBuffer,
                UInt32 nBytesInInputBuffer,
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "Deinitialize", SetLastError = true,
        CharSet = CharSet.Unicode, ExactSpelling = true,
        CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _Deinitialize();

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "DeviceIOControl", SetLastError = true,
       CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _DeviceIOControl(
                UInt32 IoControlCode,
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pInputBuffer,
                UInt32 nBytesInInputBuffer,
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "Disconnect", SetLastError = true,
        CharSet = CharSet.Unicode, ExactSpelling = true,
        CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _Disconnect();

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "GetBarcodeData", SetLastError = true,
        CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _GetBarcodeData(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "GetBarcodeDataEx", SetLastError = true,
        CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _GetBarcodeDataEx(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "GetBarcodeDataEx2", SetLastError = true,
        CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _GetBarcodeDataEx2(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "GetDllVersion", SetLastError = true,
        CharSet = CharSet.Unicode, ExactSpelling = true,
        CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _GetDllVersion([MarshalAs(UnmanagedType.LPArray)] Byte[] pOutputBuffer, UInt32 nSizeOfOutputBuffer, out UInt32 pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "GetEventNotification", SetLastError = true,
        CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _GetEventNotification(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "GetImageData", SetLastError = true,
        CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _GetImageData(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "GetSetupBarcodeData", SetLastError = true,
        CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _GetSetupBarcodeData(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "GetRawData", SetLastError = true,
        CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _GetRawData(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "ImageDataRead", SetLastError = true,
       CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _ImageDataRead(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pInputBuffer,
                UInt32 nBytesInInputBuffer,
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "Initialize", SetLastError = true,
        CharSet = CharSet.Unicode, ExactSpelling = true,
        CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _Initialise([MarshalAs(UnmanagedType.LPArray)] Byte[] pszRegistryKey, Byte[] Status);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "MessageIdentify", SetLastError = true,
        CharSet = CharSet.Unicode, ExactSpelling = true,
        CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _MessageIdentify(UInt32 handle, Byte ID);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "SetupPermissionRead", SetLastError = true,
       CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _SetupPermissionRead(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pInputBuffer,
                UInt32 nBytesInInputBuffer,
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "SetupPermissionWrite", SetLastError = true,
       CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _SetupPermissionWrite(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pInputBuffer,
                UInt32 nBytesInInputBuffer,
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "SetupRangeRead", SetLastError = true,
       CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _SetupRangeRead(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pInputBuffer,
                UInt32 nBytesInInputBuffer,
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "SetupRead", SetLastError = true,
       CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _SetupRead(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pInputBuffer,
                UInt32 nBytesInInputBuffer,
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "SetupWrite", SetLastError = true,
       CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _SetupWrite(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pInputBuffer,
                UInt32 nBytesInInputBuffer,
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "StatusPermissionRead", SetLastError = true,
       CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _StatusPermissionRead(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pInputBuffer,
                UInt32 nBytesInInputBuffer,
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "StatusPermissionWrite", SetLastError = true,
       CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _StatusPermissionWrite(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pInputBuffer,
                UInt32 nBytesInInputBuffer,
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);

    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport(DllName, EntryPoint = "StatusRead", SetLastError = true,
       CharSet = CharSet.Unicode, ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
    private static extern UInt16 _StatusRead(
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pInputBuffer,
                UInt32 nBytesInInputBuffer,
                [MarshalAs(UnmanagedType.LPArray)]Byte[] pOutputBuffer,
                UInt32 nBytesInOutputBuffer,
                [MarshalAs(UnmanagedType.LPArray)] UInt32[] pnBytesReturned);
    #endregion
    public virtual int RegisterWindowMessage(string lpString)
    {
        return _RegisterWindowMessage(lpString);
    }
    public virtual DllErrorCode ConfigurationDialog()
    {
        return (DllErrorCode)_ConfigurationDialog();
    }

    public virtual DllErrorCode Connect()
    {
        return (DllErrorCode)_Connect();
    }

    public virtual DllErrorCode ControlCommand(Byte[] pInputBuffer, UInt32 nBytesInInputBuffer, Byte[] pOutputBuffer, out UInt32 nBytesReturned)
    {
        UInt32[] len = new UInt32[1];
        UInt32 nBytesInOutputBuffer = (UInt32)pOutputBuffer.GetLength(0);
        DllErrorCode retVal = (DllErrorCode)_ControlCommand(pInputBuffer, nBytesInInputBuffer, pOutputBuffer, nBytesInOutputBuffer, len);
        nBytesReturned = len[0];
        return retVal;
    }
    public virtual DllErrorCode Deinitialize()
    {
        return (DllErrorCode)_Deinitialize();
    }
    public virtual DllErrorCode Disconnect()
    {
        return (DllErrorCode)_Disconnect();
    }

    public virtual DllErrorCode GetImageData(Byte[] pOutputBuffer, out UInt32 nBytesReturned)
    {
        UInt32[] len = new UInt32[1];
        UInt32 nBytesInOutputBuffer = (UInt32)pOutputBuffer.GetLength(0);
        DllErrorCode retVal = (DllErrorCode)_GetImageData(pOutputBuffer, nBytesInOutputBuffer, len);
        nBytesReturned = len[0];
        return retVal;
    }        
    public virtual DllErrorCode Initialise(String pszRegistryKey, out Byte Status)
    {
        Byte[] _status = new Byte[1];
        DllErrorCode _result;
        byte[] Buff = new Byte[pszRegistryKey.Length + 1];
        int test = System.Text.Encoding.ASCII.GetBytes(pszRegistryKey, 0, pszRegistryKey.Length, Buff, 0);
        byte[] buffer = System.Text.Encoding.ASCII.GetBytes(pszRegistryKey);
        _result = (DllErrorCode)_Initialise(Buff, _status);
        Status = _status[0];

        return _result;
    }
}

我有这两个功能:

public static void Test1()
{
    IsdcWrapper wrapper = new IsdcWrapper();
    wrapper.RegisterWindowMessage("WM_RAW_DATA");
    wrapper.RegisterWindowMessage("WM_ISCP_FRAME");
    wrapper.Initialise("HKCU\\SOFTWARE\\Intermec\\IsdcNetApp", out byte status);
    wrapper.ConfigurationDialog();
    Console.WriteLine(wrapper.Connect());
    byte[] inputBuffer = new byte[100];
    byte[] outputBuffer = new byte[250];
    inputBuffer[0] = 0x50;
    inputBuffer[1] = 0x40;
    inputBuffer[2] = 0x00;
    uint n;
    Console.WriteLine(wrapper.ControlCommand(inputBuffer, 3, outputBuffer, out n)); // line A
    ScannerCfg(wrapper, inputBuffer, outputBuffer);
    byte[] Barcode = new byte[500];
    Console.WriteLine(wrapper.GetImageData(Barcode, out n));
    MessageBox.Show(Encoding.ASCII.GetString(Barcode));
}
private static void ScannerCfg(IsdcWrapper wrapper,byte[] InputBuffer,byte[] OutputBuffer)
{
    byte nBytesInInputBuffer = 0;
    InputBuffer[nBytesInInputBuffer++] = 0x73; //Packeted Data format = enable
    InputBuffer[nBytesInInputBuffer++] = 0x40;
    InputBuffer[nBytesInInputBuffer++] = 0x01;

    /******************************************/
    /*     Snapshot - Image conditioning      */
    /******************************************/
    InputBuffer[nBytesInInputBuffer++] = 0x6A;
    InputBuffer[nBytesInInputBuffer++] = 0xC1;
    InputBuffer[nBytesInInputBuffer++] = 0x00;
    InputBuffer[nBytesInInputBuffer++] = 0x20;
    InputBuffer[nBytesInInputBuffer++] = 0x00;

    InputBuffer[nBytesInInputBuffer++] = 0x01; //Auto Contrast
    InputBuffer[nBytesInInputBuffer++] = 0x01; //00=None / 01=Photo / 02=Black on white / 03=white on black

    InputBuffer[nBytesInInputBuffer++] = 0x02; //Edge Enhancement
    InputBuffer[nBytesInInputBuffer++] = 0x00; //00=None / 01=Low / 02=Medium / 03=High

    InputBuffer[nBytesInInputBuffer++] = 0x03; //Image Rotation
    InputBuffer[nBytesInInputBuffer++] = 0x00; //00=None / 01=90° / 02=180° / 03=270°

    InputBuffer[nBytesInInputBuffer++] = 0x04; //Subsampling
    InputBuffer[nBytesInInputBuffer++] = 0x00; //00=None / 01=1 pixel out of 2

    InputBuffer[nBytesInInputBuffer++] = 0x05; //Noise Reduction
    InputBuffer[nBytesInInputBuffer++] = 0x00; //00 to 09 Level of noise reduction (00=none)

    InputBuffer[nBytesInInputBuffer++] = 0x07; //Image Lighting Correction
    InputBuffer[nBytesInInputBuffer++] = 0x00; //00=None / 01=Low / 02=Medium / 03=High

    InputBuffer[nBytesInInputBuffer++] = 0x09; //Reverse Video
    InputBuffer[nBytesInInputBuffer++] = 0x00; //00=Disable / 01=Enable

    InputBuffer[nBytesInInputBuffer++] = 0x41; //Color Conversion + Threshold
    InputBuffer[nBytesInInputBuffer++] = 0x00; //00=None / 01=Monochrome / 02=Enhanced
    InputBuffer[nBytesInInputBuffer++] = 0x00; //00=Very Dark / 01=Dark / 02=Normal / 03=Bright / 04=Very Bright

    InputBuffer[nBytesInInputBuffer++] = 0x42; //Output Compression + Output Compression Quality

    InputBuffer[nBytesInInputBuffer++] = 0x01; //00=Raw / 01=JPEG / 02=TIFFG4
    InputBuffer[nBytesInInputBuffer++] = 60;   //00 to 64 (0 to 100 decimal)

    InputBuffer[nBytesInInputBuffer++] = 0x80; //Cropping
    InputBuffer[nBytesInInputBuffer++] = 0x00;
    InputBuffer[nBytesInInputBuffer++] = 0x08; //8 bytes
    InputBuffer[nBytesInInputBuffer++] = 0x00;
    InputBuffer[nBytesInInputBuffer++] = 0x00; //Bytes 1 and 2 (UINT16): Left column (x)
    InputBuffer[nBytesInInputBuffer++] = 0x00;
    InputBuffer[nBytesInInputBuffer++] = 0x00; //Bytes 3 and 4 (UINT16): Top row (y)
    InputBuffer[nBytesInInputBuffer++] = 0x00;
    InputBuffer[nBytesInInputBuffer++] = 0x00; //Bytes 5 and 6 (UINT16): Width
    InputBuffer[nBytesInInputBuffer++] = 0x00;
    InputBuffer[nBytesInInputBuffer++] = 0x00; //Bytes 7 and 8 (UINT16): Height

    /******************************************/
    /*       Video - Image conditioning       */
    /******************************************/
    InputBuffer[nBytesInInputBuffer++] = 0x6A;
    InputBuffer[nBytesInInputBuffer++] = 0xC0;
    InputBuffer[nBytesInInputBuffer++] = 0x00;
    InputBuffer[nBytesInInputBuffer++] = 0x20;
    InputBuffer[nBytesInInputBuffer++] = 0x00;

    InputBuffer[nBytesInInputBuffer++] = 0x01; //Auto Contrast
    InputBuffer[nBytesInInputBuffer++] = 0x01; //00=None / 01=Photo / 02=Black on white / 03=white on black

    InputBuffer[nBytesInInputBuffer++] = 0x02; //Edge Enhancement
    InputBuffer[nBytesInInputBuffer++] = 0x00; //00=None / 01=Low / 02=Medium / 03=High

    InputBuffer[nBytesInInputBuffer++] = 0x03; //Image Rotation
    InputBuffer[nBytesInInputBuffer++] = 0x00; //00=None / 01=90° / 02=180° / 03=270°

    InputBuffer[nBytesInInputBuffer++] = 0x04; //Subsampling

    InputBuffer[nBytesInInputBuffer++] = 0x00;
    InputBuffer[nBytesInInputBuffer++] = 0x05; //Noise Reduction
    InputBuffer[nBytesInInputBuffer++] = 0x00; //00 to 09 Level of noise reduction (00=none)

    InputBuffer[nBytesInInputBuffer++] = 0x07; //Image Lighting Correction
    InputBuffer[nBytesInInputBuffer++] = 0x00; //00=None / 01=Low / 02=Medium / 03=High

    InputBuffer[nBytesInInputBuffer++] = 0x09; //Reverse Video
    InputBuffer[nBytesInInputBuffer++] = 0x00; //00=Disable / 01=Enable

    InputBuffer[nBytesInInputBuffer++] = 0x41; //Color Conversion / Threshold
    InputBuffer[nBytesInInputBuffer++] = 0x00; //00=None / 01=Monochrome / 02=Enhanced Monochrome
    InputBuffer[nBytesInInputBuffer++] = 0x00; //00=Very Dark / 01=Dark / 02=Normal / 03=Bright / 04=Very Bright

    InputBuffer[nBytesInInputBuffer++] = 0x42; //Compression/Compression Quality
    InputBuffer[nBytesInInputBuffer++] = 0x01; //00=Raw / 01=JPEG / 02=TIFFG4

    InputBuffer[nBytesInInputBuffer++] = 60; //00 to 64 (0 to 100 decimal)

    InputBuffer[nBytesInInputBuffer++] = 0x80; //Cropping
    InputBuffer[nBytesInInputBuffer++] = 0x00;
    InputBuffer[nBytesInInputBuffer++] = 0x08; //8 bytes
    InputBuffer[nBytesInInputBuffer++] = 0x00;
    InputBuffer[nBytesInInputBuffer++] = 0x00; //Bytes 1 and 2 (UINT16): Left column (x)
    InputBuffer[nBytesInInputBuffer++] = 0x00;
    InputBuffer[nBytesInInputBuffer++] = 0x00; //Bytes 3 and 4 (UINT16): Top row (y)
    InputBuffer[nBytesInInputBuffer++] = 0x00;
    InputBuffer[nBytesInInputBuffer++] = 0x00; //Bytes 5 and 6 (UINT16): Width
    InputBuffer[nBytesInInputBuffer++] = 0x00;
    InputBuffer[nBytesInInputBuffer++] = 0x00; //Bytes 7 and 8 (UINT16): Height
    Console.WriteLine(wrapper.SetupRead(InputBuffer, OutputBuffer, out uint n));
}

现在 wrapper.Connect 返回 NO_ERROR 但 A 行打印 Connection_Lost !ScannerCfg 打印中的行也是如此。

我发现 ISDC_PnP.dll 文件版本是 1.0.5,我想下载一个更高版本但我在任何地方都找不到。

有趣的是,SDK 附带的示例不起作用,并且在我的计算机上显示相同的错误。

那么为什么我会得到这个以及如何从这个条形码中读取图像呢?

附言

我更喜欢使用 SDK,因为我也想在没有键盘仿真的情况下读取条形码,但我愿意选择。

4

0 回答 0