我在我的wpf项目中使用pkcs11 dll,但我想知道我的eID阅读器有哪些驱动程序/软件版本,所以如果它是旧版本,我们可以弹出“更新eID阅读器的驱动程序”< / p>
代码的一部分:
_pkcs11 = new Pkcs11("beidpkcs11.dll", false);
LibraryInfo Lib = _pkcs11.GetInfo();
DllVersion = Lib.CryptokiVersion;
答案 0 :(得分:0)
您似乎通过托管Pkcs11Interop包装器使用PKCS#11 API来访问您的eID卡,但IMO此API不提供有关智能卡读卡器驱动程序版本的信息。您最好的方法是尝试检查HardwareVersion
类的FirmwareVersion
和/或SlotInfo
属性,其中包含有关您的smarcard阅读器的信息(在PKCS#11中称为插槽)但这些字段略有不同的含义:
using (Pkcs11 pkcs11 = new Pkcs11("beidpkcs11.dll", true))
{
List<Slot> slots = pkcs11.GetSlotList(false);
foreach (Slot slot in slots)
{
SlotInfo slotInfo = slot.GetSlotInfo();
// Examine slotInfo.HardwareVersion
// Examine slotInfo.FirmwareVersion
}
}
您还可以尝试使用SCARD_ATTR_VENDOR_IFD_VERSION
函数读取SCardGetAttrib()
reader属性,该函数是PC / SC接口的一部分,但我不确定返回的值是驱动程序版本还是设备硬件版本。以下示例使用托管pcsc-sharp包装器读取此属性:
using System;
using PCSC;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
var context = new SCardContext();
context.Establish(SCardScope.System);
var readerNames = context.GetReaders();
if (readerNames == null || readerNames.Length < 1)
{
Console.WriteLine("You need at least one reader in order to run this example.");
Console.ReadKey();
return;
}
foreach (var readerName in readerNames)
{
var reader = new SCardReader(context);
Console.Write("Trying to connect to reader.. " + readerName);
var rc = reader.Connect(readerName, SCardShareMode.Shared, SCardProtocol.Any);
if (rc != SCardError.Success)
{
Console.WriteLine(" failed. No smart card present? " + SCardHelper.StringifyError(rc) + "\n");
}
else
{
Console.WriteLine(" done.");
byte[] attribute = null;
rc = reader.GetAttrib(SCardAttribute.VendorInterfaceDeviceTypeVersion, out attribute);
if (rc != SCardError.Success)
Console.WriteLine("Error by trying to receive attribute. {0}\n", SCardHelper.StringifyError(rc));
else
Console.WriteLine("Attribute value: {0}\n", BitConverter.ToString(attribute ?? new byte[] { }));
reader.Disconnect(SCardReaderDisposition.Leave);
}
}
context.Release();
Console.ReadKey();
}
}
}
除此之外,您需要使用一些特定于操作系统的低级驱动程序API,但我不熟悉其中任何一种。