Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ScReader.h 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // Created by robin on 6/28/15.
  3. //
  4. #ifndef LIBPCSC_CPPTOOLS_SCREADER_H
  5. # define LIBPCSC_CPPTOOLS_SCREADER_H
  6. # include <wintypes.h>
  7. # include <pcsclite.h>
  8. # include <memory>
  9. #include <bits/stl_bvector.h>
  10. # include "ScCommand.h"
  11. # include "ScResult.h"
  12. class ScReader
  13. {
  14. public:
  15. inline ScReader(std::string name);
  16. virtual ~ScReader();
  17. static std::vector<std::shared_ptr<ScReader>> getReaders();
  18. static LONG getLastStaticResult();
  19. static std::string getLastStaticResultString();
  20. static std::string getResultString(const LONG& result);
  21. LONG getLastResult();
  22. std::string getLastResultString();
  23. static bool establishContext();
  24. static bool freeContext();
  25. bool connect(DWORD shareMode = SCARD_SHARE_SHARED, DWORD protocols =
  26. SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1, DWORD disposition = SCARD_LEAVE_CARD);
  27. bool disconnect(DWORD disposition = SCARD_LEAVE_CARD);
  28. std::shared_ptr<ScResult> transmit(const ScCommand& command, DWORD size = 2048);
  29. inline const std::string getName() const;
  30. std::string getAttribute(DWORD attr);
  31. std::string getAtr();
  32. private:
  33. std::string _name;
  34. static thread_local LPSCARDCONTEXT _context;
  35. static thread_local LONG _lastStaticResult;
  36. LPSCARDHANDLE _card;
  37. LPDWORD _proto;
  38. SCARD_IO_REQUEST _sendPci;
  39. LONG _lastResult;
  40. };
  41. # include "ScReader.hxx"
  42. #endif //LIBPCSC_CPPTOOLS_SCREADER_H