winscard.dll problems

  • Thread starter Jimmy Ganatsios
  • Start date
J

Jimmy Ganatsios

I am trying to connect to a smart card using C#,

While trying to connect with the smart card 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"

I haven't find a way to declare correctly ScardConnect. Currently, I am
using:

[DllImport("winscard.dll")]
public static extern int SCardConnect(int hContext, string
cReaderName,uint dwShareMode, uint dwPoutProtocol, out int phCard, out
int ActiveProtocol);

Moreover, I dont know what value 'uint dwPoutProtocol'
and 'out int ActiveProtocol' should have.

I am using Cryptoflex 8K smart card

I would be grateful if anyone could help me.

Thank you in advance.

Jimmy
 
C

Chris Tacke, eMVP

Well here's the declaration from Help:

LONG SCardConnect(
SCARDCONTEXT hContext,
LPCTSTR szReader,
DWORD dwShareMode,
DWORD dwPreferredProtocols,
LPSCARDHANDLE phCard,
LPDWORD pdwActiveProtocol
);

So that translates to:

[DllImport("winscard.dll")]
public static extern int SCardConnect(
IntPtr hContext,
string szReader,
uint dwShareMode,
uint dwPreferredProtocols,
out IntPtr phCard,
out uint pdwActiveProtocol );

Help also sheds light on the parameters:

dwPreferredProtocols
[in] Specifies a bit mask of acceptable protocols for the connection.

pdwActiveProtocol
[out] Pointer to a DWORD that receives a flag indicating the established
active protocol.

It provides a table of possible values for both.

So the answer really is that maybe checking help would be useful.

-Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top