2

I'm writing a Windows service that must handle Smart card readers.

Very often, when I try to connect to an inserted Smart card, SCardConnect() fails with SCARD_E_SHARING_VIOLATION which basically means:

The smart card cannot be accessed because of other outstanding connections.

Fair enough.

I guess that a least one other process tries to access the Smart at the same time. But is there a way to determine which process(es) it is ?

ereOn
  • 53,676
  • 39
  • 161
  • 238
  • We have noticed this problem on HP machines running HP Protect Tools and haven't been able to work around it yet (short of un-installing hp protect tools) - are you using an HP? – Damien Oct 19 '10 at 17:09

1 Answers1

3

On your place I would try with the Process Explorer to look at the file handles opened by your application if you access to the Smart card readers. To do this you should select your process and press Ctrl-H (menu "View"/"Low Pane View"/"Handes"). After you know the device name of the Smart card readers you will be able to find out other processes which use the device if you receive SCARD_E_SHARING_VIOLATION error. You should just use Ctrl-F (menu "Find"/"Find Handle or DLL...") to find file handle.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • @ereOn, Where you able to find which handle it is? – John Jul 11 '16 at 16:08
  • @Abatonime: Could you formulate your question more clear? What problem you have? Which kind of opened resources (handles) you need to localed? – Oleg Jul 11 '16 at 16:19
  • I have the exact same problem as the OP. I followed your instructions but I could not find the handle in Process Explorer. I am asking OP if he was able to find it. – John Jul 11 '16 at 18:36