Hi,
I am working with a PC/SC card reader now. I use Pinvoke to use winscard.dll
raw APIs. I finished SCardEstablishContext, SCardListReaderGroup,
SCardListReaders, SCardConnect, SCardDisconnect, SCardReleaseContext and
SCardFreeMemory. But I was stopped by SCardTransmit.
My codes:
public struct SCARD_IO_REQUEST
{
public int dwProtocol;
public int cbPciLength;
}
public static extern int SCardTransmit(int hCard, SCARD_IO_REQUEST
pioSendPci, byte[] pbSendBuffer, int cbSendLength, ref SCARD_IO_REQUEST
pioRecvPci, byte[] pbRecvBuffer,int pcbRecvLength);
When called, it returned an error code &H80100004, means invalid parameter
Can any body here tell me the right solution?
Thank you in advance
brosner@pacbell.net - 04 Sep 2004 14:21 GMT
I haven't done this this but you might try:
IntPtr DLLHandle = LoadLibrary("WINSCARD.DLL");
IntPtr scardT0Pci = GetProcAddress(DLLHandle, "g_rgSCardT0Pci");
// We are getting the address of a structure not a procedure!!
use scardT0Pci as the pioSendPci argument. The SCARD_IO_REQUEST arguments should just be IntPtrs.
Of course, you need the appropriate P/Invoke declarations for the lib calls.
It unusual and a poor design to have strange global structures exported by Dlls.