Discussion:
How to use SCardTransmit in C# (Pinvoke) ? winscard.dll problem
(too old to reply)
Windson
2004-08-24 02:23:02 UTC
Permalink
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
Bruce Rosner ()
2004-09-04 13:21:09 UTC
Permalink
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.


**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Loading...