PCSCEMV icon indicating copy to clipboard operation
PCSCEMV copied to clipboard

PCSCConnector: StackOverflow

Open plastkort opened this issue 5 years ago • 0 comments

hi and thanks for a modified PCSClibrary,

I have found an issue which im not very sure how to resolve tho.

When i connect to a reader, but keep the connection active, i do this so i can use the cardactive event to autosense... after some times, maybe 1-3 hours application crashes.

I traced the error to this code: (commented), appreciate if you can help me trace this

function CardWatcherThread(PContext: pointer): integer; var RetVar : cardinal; RContext : cardinal; RStates : array[0..1] of SCARD_READERSTATEW; begin try RContext := cardinal(PContext^); FillChar(RStates,SizeOf(RStates),#0); RStates[0].szReader := SelectedReader; RStates[0].pvUserData := nil; RStates[0].dwEventState := ActReaderState; while ReaderOpen do try RStates[0].dwCurrentState := RStates[0].dwEventState; RetVar := SCardGetStatusChangeW(RContext, 50, RStates, 1);

  // Code fails here after some time
  if RetVar <> SCARD_E_TIMEOUT then
  begin
    ActReaderState := RStates[0].dwEventState;
    PostMessage(NotifyHandle, WM_CARDSTATE, RetVar, 0);
  end;

except
  break;
end;

finally Result := 0; end; end;

plastkort avatar Jun 20 '19 07:06 plastkort