Sending APDU with winscard.dll (PC/SC) without a smart card connected

后端 未结 4 951
盖世英雄少女心
盖世英雄少女心 2021-01-26 16:38

I\'m trying to send APDU commands to the card reader itself instead of the Smart Card. The test command I\'m using turns the RF field on and off.

This commands sends ove

4条回答
  •  半阙折子戏
    2021-01-26 17:16

    Simple way is to only switch on/off Smart card reader is to call SCardEstablishContext for connecting to reader. Note : This will not connect to Smartcard:

        /// 
        /// Native SCardEstablishContext function from winscard.dll
        /// 
        /// 
        /// 
        /// 
        /// 
        /// 
        [DllImport("winscard.dll", SetLastError=true)]
        internal    static  extern  int SCardEstablishContext(UInt32 dwScope,
            IntPtr pvReserved1,
            IntPtr pvReserved2,
            IntPtr phContext);
    

    To release Reader: this will power off /Release reader handle from the current process. Note : does not have any relation to the smart card.

        /// 
        /// Native SCardReleaseContext function from winscard.dll
        /// 
        /// 
        /// 
        [DllImport("winscard.dll", SetLastError=true)]
        internal static extern  int SCardReleaseContext(UInt32 hContext);
    

提交回复
热议问题