1

我正在使用 ACS-ACR88 智能卡读卡器。我正在尝试使用SCardGetAttribin 中的函数读取智能卡序列号Winscard.dll,但它总是返回错误 50。50 未在Smart Card Return Values中定义。错误 50 是 0x32,它可能是ERROR_NOT_SUPPORTED.

我寻找可能是什么意思,发现它可能是读卡器的驱动程序!这是答案的链接:Re: SCardGetAttrib, SERIAL_NO, error 50

我已经更新了驱动程序,但没有运气。这是我到目前为止所做的:

private static UInt32 SCardAttrValue(UInt32 attrClass, UInt32 val)
{
    return (attrClass) * (2 << 16) | val;
}

private const uint SCARD_CLASS_VENDOR_DEFINED = 7;

public static UInt32 VENDOR_NAME { get { return SCardAttrValue(SCARD_CLASS_VENDOR_DEFINED, 0x100); } }

private void button2_Click(object sender, EventArgs e)
{
    var lReturn = GetAttribute((uint)hCard, VENDOR_NAME);
    lblData.Text = lReturn.ToString();    
}

public byte[] GetAttribute(uint m_hCard, UInt32 AttribId)
{
    byte[] attr = new byte[] { };// null;
    UInt32 attrLen = 0;
    attr.Initialize();
    int m_nLastError = ModWinsCard.SCardGetAttrib(m_hCard, AttribId, attr, out attrLen); //====    error 50 occurs here
    if (m_nLastError == 0)
    {
        if (attrLen != 0)
        {
            attr = new byte[attrLen];
            m_nLastError = ModWinsCard.SCardGetAttrib(m_hCard, AttribId, attr, out attrLen);
            if (m_nLastError != 0)
            {
                string msg = "SCardGetAttr error: " + m_nLastError;
                throw new Exception(msg);
            }
        }
    }
    else
    {
        string msg = "SCardGetAttr error: " + m_nLastError;
        throw new Exception(msg);
    }
}

为什么我在使用 时收到错误SCardGetAttrib,我该如何解决?

4

1 回答 1

2

也许为时已晚,但我认为您的 AttribId 值是错误的。您可以在下面的链接中查找 AttribId 值,而不是自己将十六进制转换为十进制

http://pyscard.sourceforge.net/epydoc/smartcard.scard.scard-module.html

于 2014-07-16T09:13:07.707 回答