views:

27

answers:

1

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 ?

+1  A: 

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