1

i have this sample code from smart card reader provider.

retCode = SCardConnect(hContext, _
                    cbReader.Text, _
                    SCARD_SHARE_EXCLUSIVE, _
                    SCARD_PROTOCOL_T0 Or SCARD_PROTOCOL_T1, _
                    hCard, _
                    Protocol)

What it does is connecting to smartcard.The function of SCardConnect is declared like this :

Public Declare Function SCardConnect Lib "Winscard.dll" Alias "SCardConnectA" (ByVal hContext As Long, _
                                                                           ByVal szReaderName As String, _
                                                                           ByVal dwShareMode As Long, _
                                                                           ByVal dwPrefProtocol As Long, _
                                                                           ByRef hCard As Long, _
                                                                           ByRef ActiveProtocol As Long) As Long

And i have another function of .dll in which i want it to be included while connecting to smart card.

Declare Function MineKad Lib "mineKad.dll" (ByVal field As Long, ByVal buffer As Any, resultLength As Long) As Long

I try this :

retCode = SCardConnect(MineKad, _
                    hContext, _
                    cbReader.Text, _
                    SCARD_SHARE_EXCLUSIVE, _
                    SCARD_PROTOCOL_T0 Or SCARD_PROTOCOL_T1, _
                    hCard, _
                    Protocol)

But fail... So how do i connect MineKad while connecting to smart card...MineKad is SDK that i need it to be included in order to read a card that inserted.

Azizi Musa
  • 1,009
  • 2
  • 10
  • 31
  • Just wanted to check something with you. One of the problems that I've had in the past with SDKs from older Devices is that they assume 32 bits and won't work in a 64 bit environment. You need to ensure that the SDK that you have supports the platform you're running on. Also check the windows logs. – Preet Sangha Nov 04 '13 at 04:17
  • owh. Never thought that.Checking it now. – Azizi Musa Nov 04 '13 at 04:20
  • Your sample call just seems to be adding another argument on the front -- which presumably just will not work. – Rob Nov 04 '13 at 09:27
  • 1
    @MiG Can you supply the raw C headers? Unless you do this, it's going to be guessing games all the way. – Mark Bertenshaw Nov 04 '13 at 15:51

1 Answers1

0

Note that SCardConnectA takes 6 parameters:

ByVal hContext As Long, _
ByVal szReaderName As String, _
ByVal dwShareMode As Long, _
ByVal dwPrefProtocol As Long, _
ByRef hCard As Long, _
ByRef ActiveProtocol As Long

And here you are passing 7:

retCode = SCardConnect(MineKad, _
                    hContext, _
                    cbReader.Text, _
                    SCARD_SHARE_EXCLUSIVE, _
                    SCARD_PROTOCOL_T0 Or SCARD_PROTOCOL_T1, _
                    hCard, _
                    Protocol)

Does this work instead?

retCode = SCardConnect(hContext, _
                    cbReader.Text, _
                    SCARD_SHARE_EXCLUSIVE, _
                    SCARD_PROTOCOL_T0 Or SCARD_PROTOCOL_T1, _
                    hCard, _
                    Protocol)
tcarvin
  • 10,715
  • 3
  • 31
  • 52