I'm developing a c++
application, using Visual Studio 2017.
I'm using the windows library winscard.
I'm starting with a simple project where i'm calling the function SCardEstablishContext
as the first step needed to read a smart card.
The snippet of code i'm using is the following:
LONG resContext = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hSC);
if (resContext != SCARD_S_SUCCESS) {
printf("Failed\n");
printf("Error %X\n", resContext);
}
What i know is that this function use the windows service called "Smart Card" to get the scope within which database operations are performed (read/write cards).
Unfortunately this simple application works (i.e. return the SCARD_S_SUCCESS
code) only in windows 7 environment. In all the windows 10 systems that i tested the return code is always 0x8010001DL
that is associated to the define SCARD_E_NO_SERVICE
that assert:
The Smart Card Resource Manager is not running.
On windows 7 systems the program works without admin privileges, on windows 10 systems i've tried with admin privileges too but the error is the same.
In every windows 10 system that i tested i manually started the service "Smart Card" before testing my program and checked that it still running while testing.
In both windows 7 and windows 10 systems i don't have a smart card reader connected.
The winscard.lib
file i use come with Microsoft Windows SDK
version 10.0.17763.0
There's something extra to do to get it works with windows 10?
SCARD_S_SUCCESS
, but why this behaviour? I'm still unable to get it work on win10 pc without a smart card connected. Installing that smart card driver didn't help. Maybe connecting a readed can resolve (i don't have one atm)? – Betti