0

我正在尝试使用 Windows 服务将 U.are.U 5300 指纹设备集成到我的 Web 应用程序中。我正在使用 SignalR 来回通信,但这不是问题。我有一小段代码返回连接到机器的第一个设备。

 public Reader GetReader()
        {
            if (this._reader == null)
            {
                this._reader = ReaderCollection.GetReaders()[0];
                var openResult = this._reader.Open(Constants.CapturePriority.DP_PRIORITY_COOPERATIVE);
                _res = this._reader.GetDefaultRes();
            }
            return this._reader;
        }

我反编译了硬件 dll,这是他们使用的实际代码(不确定这是否有帮助)。

 public static ReaderCollection GetReaders()
        {
            unsafe
            {
                ReaderCollection readerCollections;
                using (Tracer tracer = new Tracer("ReaderCollection::GetReaders"))
                {
                    Constants.ResultCode resultCode = Constants.ResultCode.DP_DEVICE_FAILURE;
                    if (ReaderCollection.instance == null)
                    {
                        ReaderCollection.instance = new ReaderCollection();
                        try
                        {
                            ReaderCollection.instance.m_items = new List<Reader>();
                            NativeMethods.SetDllDirectory();
                            resultCode = NativeMethods.dpfpdd_init();
                            tracer.TraceResult((int)resultCode);
                            if (!resultCode.Equals(Constants.ResultCode.DP_SUCCESS) && (int)resultCode != 1)
                            {
                                ReaderCollection.instance = null;
                                throw new SDKException(resultCode, "Could not initialize driver", new InvalidOperationException());
                            }
                            resultCode = NativeMethods.dpfj_select_engine((IntPtr)0, Constants.EngineType.DP_ENGINE_DPFJ);
                            tracer.TraceResult((int)resultCode);
                            if (!resultCode.Equals(Constants.ResultCode.DP_SUCCESS))
                            {
                                ReaderCollection.instance = null;
                                throw new SDKException(resultCode, "Could not slect Engine Type", new InvalidOperationException());
                            }
                        }
                        catch (Exception exception)
                        {
                            tracer.Trace(exception.Message);
                            ReaderCollection.instance = null;
                            throw new SDKException(Constants.ResultCode.DP_FAILURE, string.Empty, null);
                        }
                    }
                    resultCode = Constants.ResultCode.DP_FAILURE;
                    int num = 0;
                    NativeMethods.DPFPDD_DEV_INFO[] dPFPDDDEVINFOArray = null;
                    try
                    {
                        resultCode = NativeMethods.dpfpdd_query_devices(ref num, dPFPDDDEVINFOArray);
                        if (!num.Equals(0))
                        {
                            dPFPDDDEVINFOArray = new NativeMethods.DPFPDD_DEV_INFO[num];
                            dPFPDDDEVINFOArray[0].size = Marshal.SizeOf(dPFPDDDEVINFOArray[0]);
                            resultCode = NativeMethods.dpfpdd_query_devices(ref num, dPFPDDDEVINFOArray);
                            tracer.Trace(string.Format("dpfpdd_query_devices called, count is {0}", num.ToString()));
                        }
                        ReaderCollection.Refresh(dPFPDDDEVINFOArray);
                        readerCollections = ReaderCollection.instance;
                    }
                    catch (Exception exception1)
                    {
                        tracer.Trace(exception1.Message);
                        throw new SDKException(Constants.ResultCode.DP_FAILURE, string.Empty, null);
                    }
                }
                return readerCollections;
            }
        }

此代码在 Windows 窗体应用程序(桌面应用程序)中运行良好。但它无法在 Windows 服务中检测到我的设备。

  • 我已将 Windows 服务权限设置为“本地系统”
  • 启用设置“允许服务与桌面交互”

我们是否需要设置任何特殊权限(窗口或应用程序级别)来检测设备或通过 Windows 服务进行交互?

4

1 回答 1

0

得到答案:默认情况下,U.are.U SDK 安装 DigitalPersona 身份验证服务,您需要做的就是禁用此服务!

于 2020-01-13T14:04:14.383 回答