I am using ACS-ACR88 smart card reader. I am trying to read Smart Card serial number using SCardGetAttrib
function in Winscard.dll
, but it always returns error 50. 50 is not defined at Smart Card Return Values. Error 50 is 0x32, and it could be ERROR_NOT_SUPPORTED
.
I looked for what possibly it means, and found that it could mean the driver of the card reader! Here is a link of the answer: Re: SCardGetAttrib, SERIAL_NO, error 50.
I have updated the driver with no luck. Here's what I've done so far:
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);
}
}
Why am I receiving an error using SCardGetAttrib
, and how do I fix it?
SCARD_ATTR_VENDOR_IFD_SERIAL_NO
is the standard function to return the serial number. What does it return? – jww