使用 DigitalPersona 5300 采集指纹 Reader。如何检测 windows 服务中的设备?
Fingerprint capturing with DigitalPersona 5300 Reader. How to detect the device in a windows service?
我正在尝试使用 windows 服务将 U.are.U 5300 指纹设备集成到我的 Web 应用程序中。我正在使用 SignalR 来回通信,但这不是问题。我有一小段代码 returns 第一个连接到机器的设备。
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 服务权限设置为 'Local System'
- 启用
设置为 'Allow service to interact with desktop'
我们是否需要设置任何特殊权限(windows 或应用级别)来检测设备或通过 windows 服务进行交互?
得到答案:
默认情况下,U.are.U SDK 安装 DigitalPersona 身份验证服务,您需要做的就是禁用此服务!
我正在尝试使用 windows 服务将 U.are.U 5300 指纹设备集成到我的 Web 应用程序中。我正在使用 SignalR 来回通信,但这不是问题。我有一小段代码 returns 第一个连接到机器的设备。
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 服务权限设置为 'Local System'
- 启用 设置为 'Allow service to interact with desktop'
我们是否需要设置任何特殊权限(windows 或应用级别)来检测设备或通过 windows 服务进行交互?
得到答案: 默认情况下,U.are.U SDK 安装 DigitalPersona 身份验证服务,您需要做的就是禁用此服务!