windows - application working with smart card readers vs RDP and switching users -


one windows application works smart card readers. has cycle that:

do{ lerr = scardlistreaders( hcontext, ... ); if ( lerr != scard_s_success )     return 1; //show readers }while(!stop) 

i.e. gets current list of readers, shows it. problem not work correct rdp connection. let's suppose have computer (comp_a) smart card reader (reader_a), computer b (comp_b) reader b (reader_b). application launched on comp_a , shows reader_a in list of readers. connect comp_b comp_a via rdp. correct result of must there reader_b in list. application "crashes" because scardlistreaders returns scard_e_service_stopped. goggling gave answer need re-establish context. new version of cycle:

do{ lerr = scardlistreaders( hcontext, ... ); if ( lerr == scard_e_service_stopped ) {     scardreleasecontext( hcontext );     //sleep(10000)     scardestablishcontext( ..., &hcontext );     lerr = scardlistreaders( hcontext, ... ); } if ( lerr != scard_s_success )     return 1; //show readers }while(!stop) 

it not work, scardlistreaders returns reader_a in list. suppose because new scardestablishcontext ends before rdp connection set. @ least if sleep uncommented works correct. similar situation user switching, i.e. scardlistreaders returns scard_e_service_stopped when user chooses "switch user".

the question how make correct code? how determine rdp connection or user switching? how re-establish scard context?

actually made changes use wtsquerysessioninformation function wtsclientprotocoltype parameter. wait when wtsclientprotocoltype = 2 , call scardestablishcontext. not sure correct , not correct switch user.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -