Can't use winscard.h in a UWP app due to WINAPI_PARTITION_DESKTOP blocks

一笑奈何 提交于 2019-12-12 14:32:45

问题


I'm developing in C++ a Universal Windows Platform app. I have a working project in C++ which can communicate with smart cards. For this communication it uses the winscard.h library.

I'd like to use in the UWP app this functions provided by the winscard.h, but I can't compile it in the UWP. After some research I found that in this header file there is a condition:

#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)

So this is the reason the compiler doesn't found the methods. Going forward I wanted to change this WINAPI_FAMILY_PARTITION to the WINAPI_PARTITION_DESKTOP but I found nothing about this.

I set in the appxmanifest file the TargetDeviceFamily name to Windows.Desktop, but it doesn't help.

So, my questions are:

  1. Is it possible to change the WINAPI_FAMILY_PARTITION? If not:
  2. Can I use the winscard.h lib in UWP app?

回答1:


The WINAPI_PARTITION_DESKTOP guard means the API is not supported for UWP apps. It is trivial to unblock the compiler, but it's not a good idea.

  • You could unblock the compiler by making the declarations visible, but then you'd have problems linking.
  • You could manually add the correct import lib to link, but then it would likely fail at runtime due to security checks.
  • Even if you managed to make that work, your app would not be allowed in the Windows Store.
  • Even if you get it working and don't care about the Windows Store, this is not a supported scenario and could break at any point in time.

The correct way to do this is with the types in the Windows.Devices.SmartCards namespace. If there are features missing from that API, you can send feedback via UserVoice or the Feedback Hub.



来源:https://stackoverflow.com/questions/49279470/cant-use-winscard-h-in-a-uwp-app-due-to-winapi-partition-desktop-blocks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!