在win7 64bit下使用vs2019开发项目,其中有枚举PCSC读卡器并动态监视设备插拔的需求。
使用SCard这套API实现的设备枚举功能,在win7 64bit及win10 32bit上都没有问题。
当运行在Win10 64bit系统上时程序枚举不到PCSC读卡器。
搭建开发环境后发现SCardEstablishContext函数返回0x8010001D,查询错误码发现是smart card resource mananger没有启动
右键编译后exe文件以管理员身份运行也是同样的错误。
找到一个帖子:
https://docs.microsoft.com/zh-cn/archive/blogs/alejacma/scardestablishcontext-fails-with-scard_e_no_service-error
分析问题说:
SCardEstablishContext API is returning that error because it gets an Access Denied error when trying to open an event called "Global\Microsoft Smart Card Resource Manager Started" with OpenEvent API. The default security for that event on Vista and Windows 7 specifies that only SYSTEM, LOCAL SERVICE and INTERACTIVE users have access to it. NETWORK SERVICE or non-interactive users won’t be able to access the event.
Enabling "Allow service to interact with desktop" won't help.
按照帖子上的说明AddAceToObjectsSecurityDescriptor也失败,提示没有权想
有没有人遇到同样的问题?怎么解决的?