winscard 2146435026

MStone Lin
請問

我利用winscard 來讀取健保卡
我自個電腦測試正常

但到別台電腦卻出現錯誤代碼 2146435026

請問此代碼是什麼意思
少裝了什麼嗎?


Public Function ReadStatus(ByVal sICNAME As String) As Boolean
        Dim bRes As Boolean = False
        Dim context As Integer = 0
        Dim result = SCardEstablishContext(SmartCardScope.User, 0, 0, context)
        If result <> SCARD_S_SUCCESS Then Throw New Exception("Smart card error: " & result.ToString())
        Dim bufferLength As Integer = 10000
        Dim readerBuffer As Byte() = New Byte(bufferLength - 1) {}

        'result = SCardListReaders((IntPtr)context, null, readerBuffer, ref bufferLength);
        'if (result != SCARD_S_SUCCESS) throw new Exception("Smart card error: " + result.ToString());

        'var readers = ParseReaderBuffer(readerBuffer);

        'Console.WriteLine("{0} Card Reader(s)", readers.Count);
        'if (readers.Any())
        '{
        Dim readerStates As SmartCardReaderState() = New SmartCardReaderState() {New SmartCardReaderState() With {
        .cardReaderString = sICNAME
    }}

        'var readerStates = readers.Select(cardReaderName => new SmartCardReaderState() { cardReaderString = cardReaderName }).ToArray();

        result = SCardGetStatusChange(CType(context, IntPtr), 0, readerStates, readerStates.Length)
        If result <> SCARD_S_SUCCESS Then Throw New Exception("Smart card error: " & result.ToString())  '到這就出現 Smart card error: 2146435026

        If CheckIfFlagsSet(readerStates(0).eventState, SmartCardState.Present, SmartCardState.Atrmatch) Then
            bRes = True
        End If

        Return bRes

        '   readerStates.ToList().ForEach(readerState => Console.WriteLine("Reader: {0}, State: {1}", readerState.cardReaderString,
        '       CheckIfFlagsSet(readerState.eventState, SmartCardState.Present, SmartCardState.Atrmatch) ? "Card Present" : "Card Absent"));
        '}



    End Function




回到頂部