当前位置: 首页>>代码示例>>C#>>正文


C# SCardError类代码示例

本文整理汇总了C#中SCardError的典型用法代码示例。如果您正苦于以下问题:C# SCardError类的具体用法?C# SCardError怎么用?C# SCardError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SCardError类属于命名空间,在下文中一共展示了SCardError类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: connect

        public static void connect()
        {
            hContext = new SCardContext();
            hContext.Establish(SCardScope.System);

            string[] readerList = hContext.GetReaders();
            Boolean noReaders = readerList.Length <= 0;
            if (noReaders)
            {
                throw new PCSCException(SCardError.NoReadersAvailable, "Blad czytnika");
            }

            Console.WriteLine("Nazwa czytnika: " + readerList[0]);

            reader = new SCardReader(hContext);

            err = reader.Connect(readerList[0],
                SCardShareMode.Shared,
                SCardProtocol.T0 | SCardProtocol.T1);
            checkError(err);

            switch (reader.ActiveProtocol)
            {
                case SCardProtocol.T0:
                    protocol = SCardPCI.T0;
                    break;
                case SCardProtocol.T1:
                    protocol = SCardPCI.T1;
                    break;
                default:
                    throw new PCSCException(SCardError.ProtocolMismatch, "nieobslugiwany protokol: "+ reader.ActiveProtocol.ToString());
            }
        }
开发者ID:w4-pwr,项目名称:Urzadzenia-Peryferyjne,代码行数:33,代码来源:Program.cs

示例2: ThrowExceptionOnSCardError

        /// <summary>
        /// Throws an exception if <paramref name="sc"/> is not <see cref="F:PCSC.SCardError.Success"/>.
        /// </summary>
        /// <param name="sc">The error code returned from the native PC/SC library.</param>
        protected void ThrowExceptionOnSCardError(SCardError sc)
        {
            if (sc == SCardError.Success)
                return; // No Error

            // An error occurred during connect attempt.
            if (sc == SCardError.InvalidHandle)
                throw new InvalidContextException(sc);
            if (sc == SCardError.InvalidParameter)
                throw new InvalidProtocolException(sc);
            if (sc == SCardError.InvalidParameter)
                throw new InvalidParameterException(sc);
            if (sc == SCardError.InvalidValue)
                throw new InvalidValueException(sc);
            if (sc == SCardError.NoService)
                throw new NoServiceException(sc);
            if (sc == SCardError.NoSmartcard)
                throw new NoSmartcardException(sc);
            if (sc == SCardError.NotReady)
                throw new NotReadyException(sc);
            if (sc == SCardError.ReaderUnavailable)
                throw new ReaderUnavailableException(sc);
            if (sc == SCardError.SharingViolation)
                throw new SharingViolationException(sc);
            if (sc == SCardError.UnknownReader)
                throw new UnknownReaderException(sc);
            if (sc == SCardError.UnsupportedCard)
                throw new UnsupportedFeatureException(sc);
            if (sc == SCardError.CommunicationError)
                throw new CommunicationErrorException(sc);
            if (sc == SCardError.InternalError)
                throw new InternalErrorException(sc);
            if (sc == SCardError.UnpoweredCard)
                throw new UnpoweredCardException(sc);
            if (sc == SCardError.UnresponsiveCard)
                throw new UnresponsiveCardException(sc);
            if (sc == SCardError.RemovedCard)
                throw new RemovedCardException(sc);
            if (sc == SCardError.InsufficientBuffer)
                throw new InsufficientBufferException(sc);

            // unexpected error
            throw new PCSCException(sc);
        }
开发者ID:Fiware,项目名称:security.P2abcengine,代码行数:48,代码来源:IsoCard.cs

示例3: UnresponsiveCardException

 /// <summary>
 /// Initializes a new instance of the <see cref="UnresponsiveCardException"/> class.
 /// </summary>
 /// <param name="serr">System's error code</param>
 /// <param name="message">An error message text.</param>
 public UnresponsiveCardException(SCardError serr, string message)
     : base(serr, message)
 {
 }
开发者ID:bestpetrovich,项目名称:pcsc-sharp,代码行数:9,代码来源:UnresponsiveCardException.cs

示例4: InvalidValueException

 /// <summary>
 /// Initializes a new instance of the <see cref="InvalidValueException"/> class.
 /// </summary>
 /// <param name="serr">System's error code</param>
 /// <param name="message">An error message text.</param>
 /// <param name="innerException">The inner exception.</param>
 public InvalidValueException(SCardError serr, string message, Exception innerException)
     : base(serr, message, innerException)
 {
 }
开发者ID:bestpetrovich,项目名称:pcsc-sharp,代码行数:10,代码来源:InvalidValueException.cs

示例5: InvalidShareModeException

 public InvalidShareModeException(SCardError serr)
     : base(serr)
 {
 }
开发者ID:RuiVarela,项目名称:Nespresso,代码行数:4,代码来源:InvalidShareModeException.cs

示例6: InsufficientBufferException

 public InsufficientBufferException(SCardError serr)
     : base(serr) { }
开发者ID:Fiware,项目名称:security.P2abcengine,代码行数:2,代码来源:InsufficientBufferException.cs

示例7: NoServiceException

 public NoServiceException(SCardError serr, string message)
     : base(serr, message)
 {
 }
开发者ID:RuiVarela,项目名称:Nespresso,代码行数:4,代码来源:NoServiceException.cs

示例8: SharingViolationException

 public SharingViolationException(SCardError serr, string message)
     : base(serr, message)
 {
 }
开发者ID:darko0201,项目名称:eVR,代码行数:4,代码来源:SharingViolationException.cs

示例9: InvalidParameterException

 /// <summary>
 /// Creates a new instance.
 /// </summary>
 /// <param name="serr">System's error code</param>
 /// <param name="message">Error message</param>
 public InvalidParameterException(SCardError serr, string message)
     : base(serr, message) {}
开发者ID:thiti-y,项目名称:pcsc-sharp,代码行数:7,代码来源:InvalidParameterException.cs

示例10: RemovedCardException

 /// <summary>
 /// Initializes a new instance of the <see cref="RemovedCardException"/> class.
 /// </summary>
 /// <param name="serr">System's error code</param>
 /// <param name="message">An error message text.</param>
 /// <param name="innerException">The inner exception.</param>
 public RemovedCardException(SCardError serr, string message, Exception innerException)
     : base(serr, message, innerException)
 {
 }
开发者ID:bestpetrovich,项目名称:pcsc-sharp,代码行数:10,代码来源:RemovedCardException.cs

示例11: UnsupportedFeatureException

 /// <summary>
 /// Initializes a new instance of the <see cref="UnsupportedFeatureException"/> class.
 /// </summary>
 /// <param name="serr">System's error code</param>
 /// <param name="message">An error message text.</param>
 /// <param name="innerException">The inner exception.</param>
 public UnsupportedFeatureException(SCardError serr, string message, Exception innerException)
     : base(serr, message, innerException)
 {
 }
开发者ID:bestpetrovich,项目名称:pcsc-sharp,代码行数:10,代码来源:UnsupportedFeatureException.cs

示例12: PCSCException

 /// <summary>
 /// Creates a new instance.
 /// </summary>
 /// <param name="serr">System's error code</param>
 public PCSCException(SCardError serr)
     : base(SCardHelper.StringifyError(serr)) {
     SCardError = serr;
 }
开发者ID:thiti-y,项目名称:pcsc-sharp,代码行数:8,代码来源:PCSCException.cs

示例13: sendCommand

 public static void sendCommand(byte[] comand, String name)
 {
     byte[] recivedBytes = new byte[256];
     err = reader.Transmit(protocol, comand, ref recivedBytes);
     checkError(err);
     writeResponse(recivedBytes, name);
 }
开发者ID:w4-pwr,项目名称:Urzadzenia-Peryferyjne,代码行数:7,代码来源:Program.cs


注:本文中的SCardError类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。