Windows 生物识别框架:AcquireFocus() 不工作。错误访问被拒绝:0x80070005
Windows Biometric Framework: AcquireFocus() not wokring. Error AccessDenied : 0x80070005
我正在开发 windows 服务来捕获指纹样本。 WBF(Windows Bio metric Framework)需要对焦来捕获样本图像,为此我正在使用 AcquireFocus()。
从DLL导出如下。
class Focus
{
protected const string LibName = "winbio.dll";
[DllImport(LibName, EntryPoint = "WinBioAcquireFocus")]
public static extern WinBioErrorCode WinBioAcquireFocus();
[DllImport(LibName, EntryPoint = "WinBioReleaseFocus")]
public static extern WinBioErrorCode WinBioReleaseFocus();
}
用法如下
WriteToFile(DateTime.Now + " Acquiring Focus" + "\n");
re = Focus.WinBioAcquireFocus();
if (re.Equals(WinBioErrorCode.Ok)){
WriteToFile(DateTime.Now + " Calling CaptureSample Image." + "\n");
result = wbf.CaptureSampleImage();
}
else{
WriteToFile(DateTime.Now + " Error in Acquiring Focus: " + re + "\n");
}
此功能要求进程在 documnetation 中提到的 LocalSystem 帐户上 运行。
我已经在服务设置中设置了这个。
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
CaptureSampleImage() 在 DLL 中定义。
现在我总是收到错误 0x80070005,即访问被拒绝。日志文件如下。
10/22/2019 4:16:06 PM Acquiring Focus
10/22/2019 4:16:06 PM Error in Acquiring Focus: AccessDenied
10/22/2019 4:16:06 PM Stopping Service.
错误码定义为Enum如下
public enum WinBioErrorCode
: uint
{
Ok = 0,
False = 1,
AccessDenied = 0x80070005,
...
}
documnetation 说这是因为服务不在 LocalSystem 上,而它是。
出于日志目的,我编写了 writeToFile(message),将消息写入 .txt 文件。
我该怎么做才能消除这个错误?
提前致谢。
在 WinBioOpenSession() 之后添加 AcquireFocus()。然后它将获得该会话的焦点并且 return S_OK.
我正在开发 windows 服务来捕获指纹样本。 WBF(Windows Bio metric Framework)需要对焦来捕获样本图像,为此我正在使用 AcquireFocus()。
从DLL导出如下。
class Focus
{
protected const string LibName = "winbio.dll";
[DllImport(LibName, EntryPoint = "WinBioAcquireFocus")]
public static extern WinBioErrorCode WinBioAcquireFocus();
[DllImport(LibName, EntryPoint = "WinBioReleaseFocus")]
public static extern WinBioErrorCode WinBioReleaseFocus();
}
用法如下
WriteToFile(DateTime.Now + " Acquiring Focus" + "\n");
re = Focus.WinBioAcquireFocus();
if (re.Equals(WinBioErrorCode.Ok)){
WriteToFile(DateTime.Now + " Calling CaptureSample Image." + "\n");
result = wbf.CaptureSampleImage();
}
else{
WriteToFile(DateTime.Now + " Error in Acquiring Focus: " + re + "\n");
}
此功能要求进程在 documnetation 中提到的 LocalSystem 帐户上 运行。 我已经在服务设置中设置了这个。
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
CaptureSampleImage() 在 DLL 中定义。 现在我总是收到错误 0x80070005,即访问被拒绝。日志文件如下。
10/22/2019 4:16:06 PM Acquiring Focus
10/22/2019 4:16:06 PM Error in Acquiring Focus: AccessDenied
10/22/2019 4:16:06 PM Stopping Service.
错误码定义为Enum如下
public enum WinBioErrorCode
: uint
{
Ok = 0,
False = 1,
AccessDenied = 0x80070005,
...
}
documnetation 说这是因为服务不在 LocalSystem 上,而它是。
出于日志目的,我编写了 writeToFile(message),将消息写入 .txt 文件。
我该怎么做才能消除这个错误?
提前致谢。
在 WinBioOpenSession() 之后添加 AcquireFocus()。然后它将获得该会话的焦点并且 return S_OK.