我正在尝试使用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 服务进行交互?
得到答案: 默认情况下,U.are.U SDK会安装DigitalPersona身份验证服务,您需要做的就是禁用此服务!