Reputation: 227
I'm trying to integrate the U.are.U 5300 Fingerprint device in my web application using windows service. I'm using SignalR to communicate back and forth, but that isn't a problem. I've a small piece of code which returns the first device that is attached to the machine.
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;
}
I de-compiled the hardware dll and this is the actual code that they use (not sure if this will help).
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;
}
}
This code works fine in a windows form application (desktop application). But it is not able to detect my device in a windows service.
Do we have any special permissions (windows or app level) that we need to set to detect the device or interact through a windows service?
Upvotes: 1
Views: 2078
Reputation: 227
Got the answer: By default the U.are.U SDK installs the DigitalPersona Authenication Service, all you need to do is disable this service!
Upvotes: 0