Smartcard SCardConnect call failure

  • Thread starter Thread starter Jonas
  • Start date Start date
J

Jonas

Hi!

When I try call the SCardConnect function from the winscard.dll it fails.
When I run the same code in an ordinary WinForm application if works without
any problem.

Declaration:

[DllImport ("winscard.dll", SetLastError=true)]
private static extern uint SCardConnect (
int hContext,
string szReader,
int dwShareMode,
int dwPreferredProtocols,
ref int hCard,
ref int dwActiveProtocol);

Call:

rc = SCardConnect(hContext, curReader, dwShareMode, dwPreferredProtocols,
ref hCard, ref dwActiveProtocol);

hContext = -216111414
curReader = "OMNIKEY CardMan 4040 0"
dwShareMode = 2
dwPreferredProtocols = 1
hCard = 0
dwActiveProtocol = 0

I get a return value of 2148532241 which translates into the error:

"One or more of the supplied parameters values could not be properly
interpreted"

My guess is that this has something to do with the fact that the WindowsCE
OS is Unicode only, which in some way affects the call to SCardConnect.

Any tips on this?

Brgds

Jonas
 
Back
Top